Commit 8d3e00a0 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #3843 from CocoaPods/seg-xcconfig-config

[AggregateXCConfig] Only include settings for the current build config
parents 129ea5f4 fc2c2bbf
...@@ -4,6 +4,16 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -4,6 +4,16 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
To install release candidates run `[sudo] gem install cocoapods --pre` To install release candidates run `[sudo] gem install cocoapods --pre`
## Master
##### Bug Fixes
* Ensure the aggregate `.xcconfig` file only has the settings for the
appropriate build configuration.
[#3842](https://github.com/CocoaPods/CocoaPods/issues/3842)
[Samuel Giddins](https://github.com/segiddins)
## 0.38.0 ## 0.38.0
##### Enhancements ##### Enhancements
......
...@@ -8,13 +8,16 @@ module Pod ...@@ -8,13 +8,16 @@ module Pod
# #
attr_reader :target attr_reader :target
# @return [String] the name of the build configuration to generate this
# xcconfig for.
#
attr_reader :configuration_name
# Initialize a new instance # Initialize a new instance
# #
# @param [Target] target @see target # @param [Target] target @see target
# #
# @param [String] configuration_name # @param [String] configuration_name @see configuration_name
# The name of the build configuration to generate this xcconfig
# for.
# #
def initialize(target, configuration_name) def initialize(target, configuration_name)
@target = target @target = target
...@@ -50,7 +53,7 @@ module Pod ...@@ -50,7 +53,7 @@ module Pod
# #
def generate def generate
includes_static_libs = !target.requires_frameworks? includes_static_libs = !target.requires_frameworks?
includes_static_libs ||= target.pod_targets.flat_map(&:file_accessors).any? { |fa| !fa.vendored_libraries.empty? } includes_static_libs ||= pod_targets.flat_map(&:file_accessors).any? { |fa| !fa.vendored_libraries.empty? }
config = { config = {
'OTHER_LDFLAGS' => '$(inherited) ' + XCConfigHelper.default_ld_flags(target, includes_static_libs), 'OTHER_LDFLAGS' => '$(inherited) ' + XCConfigHelper.default_ld_flags(target, includes_static_libs),
'PODS_ROOT' => target.relative_pods_root, 'PODS_ROOT' => target.relative_pods_root,
...@@ -91,7 +94,7 @@ module Pod ...@@ -91,7 +94,7 @@ module Pod
def generate_settings_to_import_pod_targets def generate_settings_to_import_pod_targets
if target.requires_frameworks? if target.requires_frameworks?
# Framework headers are automatically discoverable by `#import <…>`. # Framework headers are automatically discoverable by `#import <…>`.
header_search_paths = target.pod_targets.map do |target| header_search_paths = pod_targets.map do |target|
if target.scoped? if target.scoped?
"$PODS_FRAMEWORK_BUILD_PATH/#{target.product_name}/Headers" "$PODS_FRAMEWORK_BUILD_PATH/#{target.product_name}/Headers"
else else
...@@ -103,7 +106,7 @@ module Pod ...@@ -103,7 +106,7 @@ module Pod
# Make headers discoverable by `import "…"` # Make headers discoverable by `import "…"`
'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_paths, '-iquote'), 'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_paths, '-iquote'),
} }
if target.pod_targets.any? { |t| t.should_build? && t.scoped? } if pod_targets.any? { |t| t.should_build? && t.scoped? }
build_settings['FRAMEWORK_SEARCH_PATHS'] = '$(inherited) "$PODS_FRAMEWORK_BUILD_PATH"' build_settings['FRAMEWORK_SEARCH_PATHS'] = '$(inherited) "$PODS_FRAMEWORK_BUILD_PATH"'
end end
@xcconfig.merge!(build_settings) @xcconfig.merge!(build_settings)
...@@ -130,7 +133,7 @@ module Pod ...@@ -130,7 +133,7 @@ module Pod
# user target. # user target.
# #
def generate_vendored_build_settings def generate_vendored_build_settings
target.pod_targets.each do |pod_target| pod_targets.each do |pod_target|
unless pod_target.should_build? && pod_target.requires_frameworks? unless pod_target.should_build? && pod_target.requires_frameworks?
XCConfigHelper.add_settings_for_file_accessors_of_target(pod_target, @xcconfig) XCConfigHelper.add_settings_for_file_accessors_of_target(pod_target, @xcconfig)
end end
...@@ -141,7 +144,7 @@ module Pod ...@@ -141,7 +144,7 @@ module Pod
# with the user’s project. # with the user’s project.
# #
def generate_other_ld_flags def generate_other_ld_flags
other_ld_flags = target.pod_targets.select(&:should_build?).map do |pod_target| other_ld_flags = pod_targets.select(&:should_build?).map do |pod_target|
if pod_target.requires_frameworks? if pod_target.requires_frameworks?
%(-framework "#{pod_target.product_basename}") %(-framework "#{pod_target.product_basename}")
else else
...@@ -191,7 +194,7 @@ module Pod ...@@ -191,7 +194,7 @@ module Pod
# @return [Array<PodTarget>] # @return [Array<PodTarget>]
# #
def pod_targets def pod_targets
target.pod_targets_for_build_configuration(@configuration_name) target.pod_targets_for_build_configuration(configuration_name)
end end
# Returns the +user_target_xcconfig+ for all pod targets and their spec # Returns the +user_target_xcconfig+ for all pod targets and their spec
......
...@@ -214,6 +214,23 @@ module Pod ...@@ -214,6 +214,23 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe 'when no pods are whitelisted for the given configuration' do
before do
@generator.stubs(:configuration_name).returns('.invalid')
@xcconfig = @generator.generate
end
it 'does not link with vendored frameworks' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-framework "Bananalib"'
end
it 'does not link with vendored libraries' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-l"Bananalib"'
end
end
#-----------------------------------------------------------------------#
describe 'with multiple pod targets with user_target_xcconfigs' do describe 'with multiple pod targets with user_target_xcconfigs' do
before do before do
spec_b = fixture_spec('orange-framework/OrangeFramework.podspec') spec_b = fixture_spec('orange-framework/OrangeFramework.podspec')
......
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