Commit 43502d3f authored by Marius Rackwitz's avatar Marius Rackwitz

Merge pull request #3573 from CocoaPods/mr-fix-xcconfig

Split xcconfig to pod_target_xcconfig and user_target_xcconfig
parents b45a5189 4fe8f24d
...@@ -18,6 +18,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -18,6 +18,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Marius Rackwitz](https://github.com/mrackwitz) [Marius Rackwitz](https://github.com/mrackwitz)
[#3648](https://github.com/CocoaPods/CocoaPods/issues/3648) [#3648](https://github.com/CocoaPods/CocoaPods/issues/3648)
* Deprecate the `xcconfig` attribute in the Podspec DSL, which is replaced by
the new attributes `pod_target_xcconfig` and `user_target_xcconfig`.
[Marius Rackwitz](https://github.com/mrackwitz)
[CocoaPods#3465](https://github.com/CocoaPods/CocoaPods/issues/3465)
##### Enhancements ##### Enhancements
* The notice about a new version being available will now include our * The notice about a new version being available will now include our
......
...@@ -7,7 +7,7 @@ GIT ...@@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: d464a13852d6642e115cce0c00945a09cb0f6d5a revision: 977fd7d2a19b9f9a861af7a76b8af64136f574fc
branch: master branch: master
specs: specs:
cocoapods-core (0.37.2) cocoapods-core (0.37.2)
......
...@@ -49,7 +49,6 @@ module Pod ...@@ -49,7 +49,6 @@ module Pod
# @return [Xcodeproj::Config] # @return [Xcodeproj::Config]
# #
def generate def generate
pod_targets = target.pod_targets_for_build_configuration(@configuration_name)
config = { config = {
'OTHER_LDFLAGS' => '$(inherited) ' + XCConfigHelper.default_ld_flags(target), 'OTHER_LDFLAGS' => '$(inherited) ' + XCConfigHelper.default_ld_flags(target),
'PODS_ROOT' => target.relative_pods_root, 'PODS_ROOT' => target.relative_pods_root,
...@@ -104,6 +103,8 @@ module Pod ...@@ -104,6 +103,8 @@ module Pod
end end
end end
@xcconfig.merge!(merged_user_target_xcconfigs)
# TODO: Need to decide how we are going to ensure settings like these # TODO: Need to decide how we are going to ensure settings like these
# are always excluded from the user's project. # are always excluded from the user's project.
# #
...@@ -134,6 +135,70 @@ module Pod ...@@ -134,6 +135,70 @@ module Pod
@xcconfig.merge!('LD_RUNPATH_SEARCH_PATHS' => ld_runpath_search_paths.join(' ')) @xcconfig.merge!('LD_RUNPATH_SEARCH_PATHS' => ld_runpath_search_paths.join(' '))
end end
private
#---------------------------------------------------------------------#
# !@group Private Helpers
# Returns the {PodTarget}s which are active for the current
# configuration name.
#
# @return [Array<PodTarget>]
#
def pod_targets
target.pod_targets_for_build_configuration(@configuration_name)
end
# Returns the +user_target_xcconfig+ for all pod targets grouped by keys
#
# @return [Hash{String,Hash{Target,String}]
#
def user_target_xcconfig_values_by_target_by_key
pod_targets.each_with_object({}) do |target, hash|
target.spec_consumers.each do |spec_consumer|
spec_consumer.user_target_xcconfig.each do |k, v|
(hash[k] ||= {})[target] = v
end
end
end
end
# Merges the +user_target_xcconfig+ for all pod targets into the
# #xcconfig and warns on conflicting definitions.
#
# @return [Hash{String, String}]
#
def merged_user_target_xcconfigs
settings = user_target_xcconfig_values_by_target_by_key
settings.each_with_object({}) do |(key, values_by_target), xcconfig|
uniq_values = values_by_target.values.uniq
values_are_bools = uniq_values.all? { |v| v =~ /(yes|no)/i }
if values_are_bools
# Boolean build settings
if uniq_values.count > 1
UI.warn 'Can\'t merge user_target_xcconfig for pod targets: ' \
"#{values_by_target.keys.map(&:label)}. Boolean build "\
"setting #{key} has different values."
else
xcconfig[key] = uniq_values.first
end
elsif key =~ /S$/
# Plural build settings
xcconfig[key] = uniq_values.join(' ')
else
# Singular build settings
if uniq_values.count > 1
UI.warn 'Can\'t merge user_target_xcconfig for pod targets: ' \
"#{values_by_target.keys.map(&:label)}. Singular build "\
"setting #{key} has different values."
else
xcconfig[key] = uniq_values.first
end
end
end
end
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
end end
end end
......
...@@ -70,7 +70,7 @@ module Pod ...@@ -70,7 +70,7 @@ module Pod
# The xcconfig to edit. # The xcconfig to edit.
# #
def self.add_spec_build_settings_to_xcconfig(consumer, xcconfig) def self.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.merge!(consumer.xcconfig) xcconfig.merge!(consumer.pod_target_xcconfig)
xcconfig.libraries.merge(consumer.libraries) xcconfig.libraries.merge(consumer.libraries)
xcconfig.frameworks.merge(consumer.frameworks) xcconfig.frameworks.merge(consumer.frameworks)
xcconfig.weak_frameworks.merge(consumer.weak_frameworks) xcconfig.weak_frameworks.merge(consumer.weak_frameworks)
......
Subproject commit 5eb5a14245f90d0a7cce21113a7fafaec022423f Subproject commit 0ce7a32ea385cf641ef76bd7f5a8166c554086d3
...@@ -46,7 +46,7 @@ module Pod ...@@ -46,7 +46,7 @@ module Pod
end end
it 'returns the slug' do it 'returns the slug' do
@request.slug.should == 'Release/BananaLib/1.0-07e5b' @request.slug.should == 'Release/BananaLib/1.0-59a13'
end end
end end
......
...@@ -170,6 +170,70 @@ module Pod ...@@ -170,6 +170,70 @@ module Pod
generated.class.should == Xcodeproj::Config generated.class.should == Xcodeproj::Config
end end
end end
#-----------------------------------------------------------------------#
describe 'with multiple pod targets with user_target_xcconfigs' do
before do
spec_b = fixture_spec('orange-framework/OrangeFramework.podspec')
@pod_target_b = fixture_pod_target(spec_b)
@consumer_a = @consumer
@consumer_b = @pod_target_b.spec_consumers.last
@target.pod_targets << @pod_target_b
end
describe 'with boolean build settings' do
it 'does not warn if the values are equal' do
@consumer_a.stubs(:user_target_xcconfig).returns('ENABLE_HEADER_DEPENDENCIES' => 'YES')
@consumer_b.stubs(:user_target_xcconfig).returns('ENABLE_HEADER_DEPENDENCIES' => 'YES')
@xcconfig = @generator.generate
@xcconfig.to_hash['ENABLE_HEADER_DEPENDENCIES'].should == 'YES'
end
it 'warns if the values differ' do
@consumer_a.stubs(:user_target_xcconfig).returns('ENABLE_HEADER_DEPENDENCIES' => 'YES')
@consumer_b.stubs(:user_target_xcconfig).returns('ENABLE_HEADER_DEPENDENCIES' => 'NO')
@xcconfig = @generator.generate
UI.warnings.should.include 'Can\'t merge user_target_xcconfig for pod targets: ' \
'["Pods-BananaLib", "Pods-OrangeFramework"]. Boolean build setting '\
'ENABLE_HEADER_DEPENDENCIES has different values.'
end
end
describe 'with list build settings' do
it 'only adds the value once if the values are equal' do
@consumer_a.stubs(:user_target_xcconfig).returns('OTHER_CPLUSPLUSFLAGS' => '-std=c++1y')
@consumer_b.stubs(:user_target_xcconfig).returns('OTHER_CPLUSPLUSFLAGS' => '-std=c++1y')
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_CPLUSPLUSFLAGS'].should == '-std=c++1y'
end
it 'adds both values if the values differ' do
@consumer_a.stubs(:user_target_xcconfig).returns('OTHER_CPLUSPLUSFLAGS' => '-std=c++1y')
@consumer_b.stubs(:user_target_xcconfig).returns('OTHER_CPLUSPLUSFLAGS' => '-stdlib=libc++')
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_CPLUSPLUSFLAGS'].should == '-std=c++1y -stdlib=libc++'
end
end
describe 'with singular build settings' do
it 'does not warn if the values are equal' do
@consumer_a.stubs(:user_target_xcconfig).returns('STRIP_STYLE' => 'non-global')
@consumer_b.stubs(:user_target_xcconfig).returns('STRIP_STYLE' => 'non-global')
@xcconfig = @generator.generate
@xcconfig.to_hash['STRIP_STYLE'].should == 'non-global'
end
it 'does warn if the values differ' do
@consumer_a.stubs(:user_target_xcconfig).returns('STRIP_STYLE' => 'non-global')
@consumer_b.stubs(:user_target_xcconfig).returns('STRIP_STYLE' => 'all')
@xcconfig = @generator.generate
UI.warnings.should.include 'Can\'t merge user_target_xcconfig for pod targets: ' \
'["Pods-BananaLib", "Pods-OrangeFramework"]. Singular build setting '\
'STRIP_STYLE has different values.'
end
end
end
end end
end end
end end
......
...@@ -49,7 +49,7 @@ module Pod ...@@ -49,7 +49,7 @@ module Pod
it 'adds the build settings of the consumer' do it 'adds the build settings of the consumer' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub( consumer = stub(
:xcconfig => { 'OTHER_LDFLAGS' => '-framework SenTestingKit' }, :pod_target_xcconfig => { 'OTHER_LDFLAGS' => '-framework SenTestingKit' },
:libraries => [], :libraries => [],
:frameworks => [], :frameworks => [],
:weak_frameworks => [], :weak_frameworks => [],
...@@ -62,7 +62,7 @@ module Pod ...@@ -62,7 +62,7 @@ module Pod
it 'adds the libraries of the xcconfig' do it 'adds the libraries of the xcconfig' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub( consumer = stub(
:xcconfig => {}, :pod_target_xcconfig => {},
:libraries => ['xml2'], :libraries => ['xml2'],
:frameworks => [], :frameworks => [],
:weak_frameworks => [], :weak_frameworks => [],
...@@ -75,7 +75,7 @@ module Pod ...@@ -75,7 +75,7 @@ module Pod
it 'adds the frameworks of the xcconfig' do it 'adds the frameworks of the xcconfig' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub( consumer = stub(
:xcconfig => {}, :pod_target_xcconfig => {},
:libraries => [], :libraries => [],
:frameworks => ['CoreAnimation'], :frameworks => ['CoreAnimation'],
:weak_frameworks => [], :weak_frameworks => [],
...@@ -88,7 +88,7 @@ module Pod ...@@ -88,7 +88,7 @@ module Pod
it 'adds the weak frameworks of the xcconfig' do it 'adds the weak frameworks of the xcconfig' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub( consumer = stub(
:xcconfig => {}, :pod_target_xcconfig => {},
:libraries => [], :libraries => [],
:frameworks => [], :frameworks => [],
:weak_frameworks => ['iAd'], :weak_frameworks => ['iAd'],
...@@ -101,7 +101,7 @@ module Pod ...@@ -101,7 +101,7 @@ module Pod
it 'adds the ios developer frameworks search paths if needed' do it 'adds the ios developer frameworks search paths if needed' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub( consumer = stub(
:xcconfig => {}, :pod_target_xcconfig => {},
:libraries => [], :libraries => [],
:frameworks => ['SenTestingKit'], :frameworks => ['SenTestingKit'],
:weak_frameworks => [], :weak_frameworks => [],
...@@ -115,7 +115,7 @@ module Pod ...@@ -115,7 +115,7 @@ module Pod
it 'adds the osx developer frameworks search paths if needed' do it 'adds the osx developer frameworks search paths if needed' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub( consumer = stub(
:xcconfig => {}, :pod_target_xcconfig => {},
:libraries => [], :libraries => [],
:frameworks => ['SenTestingKit'], :frameworks => ['SenTestingKit'],
:weak_frameworks => [], :weak_frameworks => [],
......
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