Commit b233a8a9 authored by Fabio Pelosin's avatar Fabio Pelosin

[Project] Add preprocessor definition for build configurations

parent 55a8c912
...@@ -18,7 +18,7 @@ GIT ...@@ -18,7 +18,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 730a09310e986bb2ec5430ef303f8453537d01ac revision: 7dd77ed01ce5e2cfddc2dc9307a8cfdf9ce78e52
branch: master branch: master
specs: specs:
xcodeproj (0.18.0) xcodeproj (0.18.0)
......
...@@ -193,6 +193,36 @@ module Pod ...@@ -193,6 +193,36 @@ module Pod
podfile_ref podfile_ref
end end
# Adds a new build configuration to the project and populates its with
# default settings according to the provided type.
#
# @note This method extends the original Xcodeproj implementation to
# include a preprocessor definition named after the build
# setting. This is done to support the TargetEnvironmentHeader
# specification of Pods available only on certain build
# configurations.
#
# @param [String] name
# The name of the build configuration.
#
# @param [Symbol] type
# The type of the build configuration used to populate the build
# settings, must be :debug or :release.
#
# @return [XCBuildConfiguration] The new build configuration.
#
def add_build_configuration(name, type)
build_configuration = super
values = ["#{name.gsub(' ', '_').upcase}=1"]
settings = build_configuration.build_settings
values.each do |value|
definitions = settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= []
unless definitions.include?(value)
definitions << value
end
end
build_configuration
end
private private
......
Subproject commit 3200e10190c6892b837e5ef3b87c2a2a612f69b6 Subproject commit f10519fd4b3e699dfee488edf761b0ebe675f5b2
...@@ -225,6 +225,36 @@ module Pod ...@@ -225,6 +225,36 @@ module Pod
f.path.should == '../Podfile' f.path.should == '../Podfile'
end end
#----------------------------------------#
describe "#add_build_configuration" do
it "adds a preprocessor definition for build configurations" do
configuration = @project.add_build_configuration('Release', :release)
settings = configuration.build_settings
settings['GCC_PREPROCESSOR_DEFINITIONS'].should.include('RELEASE=1')
end
it "doesn't duplicate values" do
original = @project.build_configuration_list['Debug']
original_settings = original.build_settings
original_settings['GCC_PREPROCESSOR_DEFINITIONS'].should ==
["DEBUG=1", "$(inherited)"]
configuration = @project.add_build_configuration('Debug', :debug)
settings = configuration.build_settings
settings['GCC_PREPROCESSOR_DEFINITIONS'].should ==
["DEBUG=1", "$(inherited)"]
end
it "normalizes the name of the configuration" do
configuration = @project.add_build_configuration(
'My Awesome Configuration', :release)
settings = configuration.build_settings
settings['GCC_PREPROCESSOR_DEFINITIONS'].should ==
["MY_AWESOME_CONFIGURATION=1"]
end
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment