Commit b47fb398 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[AggregateXCConfig] Properly merge the user_target_xcconfigs of multiple subspecs.

Closes https://github.com/CocoaPods/CocoaPods/issues/3813.
parent c3672f99
......@@ -14,6 +14,13 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[#3830](https://github.com/CocoaPods/CocoaPods/pull/3830)
[Eloy Durán](https://github.com/alloy)
##### Bug Fixes
* Properly merge the `user_target_xcconfig`s of multiple subspecs.
[#3813](https://github.com/CocoaPods/CocoaPods/issues/3813)
[Samuel Giddins](https://github.com/segiddins)
## 0.38.0.beta.2
##### Enhancements
......
......@@ -194,15 +194,16 @@ module Pod
target.pod_targets_for_build_configuration(@configuration_name)
end
# Returns the +user_target_xcconfig+ for all pod targets grouped by keys
# Returns the +user_target_xcconfig+ for all pod targets and their spec
# consumers grouped by keys
#
# @return [Hash{String,Hash{Target,String}]
#
def user_target_xcconfig_values_by_target_by_key
def user_target_xcconfig_values_by_consumer_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
(hash[k] ||= {})[spec_consumer] = v
end
end
end
......@@ -214,7 +215,7 @@ module Pod
# @return [Hash{String, String}]
#
def merged_user_target_xcconfigs
settings = user_target_xcconfig_values_by_target_by_key
settings = user_target_xcconfig_values_by_consumer_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 }
......@@ -222,7 +223,7 @@ module Pod
# 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 "\
"#{values_by_target.keys.map(&:name)}. Boolean build "\
"setting #{key} has different values."
else
xcconfig[key] = uniq_values.first
......@@ -234,7 +235,7 @@ module Pod
# 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 "\
"#{values_by_target.keys.map(&:name)}. Singular build "\
"setting #{key} has different values."
else
xcconfig[key] = uniq_values.first
......
......@@ -255,6 +255,14 @@ module Pod
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_CPLUSPLUSFLAGS'].should == '-std=c++1y -stdlib=libc++'
end
it 'adds values from all subspecs' do
@consumer_b.stubs(:user_target_xcconfig).returns('OTHER_CPLUSPLUSFLAGS' => '-std=c++1y')
consumer_c = mock(:user_target_xcconfig => { 'OTHER_CPLUSPLUSFLAGS' => '-stdlib=libc++' })
@pod_target_b.stubs(:spec_consumers).returns([@consumer_b, consumer_c])
@xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_CPLUSPLUSFLAGS'].should == '-std=c++1y -stdlib=libc++'
end
end
describe 'with singular build settings' do
......
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