Unverified Commit 4e212684 authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7177 from dnkoutso/pod_xcconfig_fix

Do not propagate test spec frameworks and libraries into pod target xcconfig
parents cb9e2a2e 4c879e62
...@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes ##### Bug Fixes
* Do not propagate test spec frameworks and libraries into pod target xcconfig
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7172](https://github.com/CocoaPods/CocoaPods/issues/7172)
* Set language to Swift for test native targets if any dependencies use Swift * Set language to Swift for test native targets if any dependencies use Swift
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7170](https://github.com/CocoaPods/CocoaPods/issues/7170) [#7170](https://github.com/CocoaPods/CocoaPods/issues/7170)
......
...@@ -64,18 +64,18 @@ module Pod ...@@ -64,18 +64,18 @@ module Pod
@xcconfig = Xcodeproj::Config.new(config) @xcconfig = Xcodeproj::Config.new(config)
XCConfigHelper.add_settings_for_file_accessors_of_target(nil, target, @xcconfig) XCConfigHelper.add_settings_for_file_accessors_of_target(nil, target, @xcconfig, true, @test_xcconfig)
target.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
@xcconfig.merge!(file_accessor.spec_consumer.pod_target_xcconfig) if @test_xcconfig == file_accessor.spec.test_specification? @xcconfig.merge!(file_accessor.spec_consumer.pod_target_xcconfig) if @test_xcconfig == file_accessor.spec.test_specification?
end end
XCConfigHelper.add_target_specific_settings(target, @xcconfig) XCConfigHelper.add_target_specific_settings(target, @xcconfig)
recursive_dependent_targets = target.recursive_dependent_targets recursive_dependent_targets = target.recursive_dependent_targets
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, recursive_dependent_targets, @test_xcconfig) @xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, recursive_dependent_targets, @test_xcconfig)
XCConfigHelper.generate_vendored_build_settings(target, recursive_dependent_targets, @xcconfig, false) if target.requires_frameworks? XCConfigHelper.generate_vendored_build_settings(target, recursive_dependent_targets, @xcconfig, false, @test_xcconfig) if target.requires_frameworks?
if @test_xcconfig if @test_xcconfig
test_dependent_targets = [target, *target.recursive_test_dependent_targets].uniq test_dependent_targets = [target, *target.recursive_test_dependent_targets].uniq
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, test_dependent_targets - recursive_dependent_targets, @test_xcconfig) @xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, test_dependent_targets - recursive_dependent_targets, @test_xcconfig)
XCConfigHelper.generate_vendored_build_settings(nil, target.all_test_dependent_targets, @xcconfig) XCConfigHelper.generate_vendored_build_settings(nil, target.all_test_dependent_targets, @xcconfig, true, @test_xcconfig)
XCConfigHelper.generate_other_ld_flags(nil, target.all_test_dependent_targets, @xcconfig) XCConfigHelper.generate_other_ld_flags(nil, target.all_test_dependent_targets, @xcconfig)
XCConfigHelper.generate_ld_runpath_search_paths(target, false, true, @xcconfig) XCConfigHelper.generate_ld_runpath_search_paths(target, false, true, @xcconfig)
end end
......
...@@ -75,19 +75,24 @@ module Pod ...@@ -75,19 +75,24 @@ module Pod
# @param [Boolean] include_ld_flags # @param [Boolean] include_ld_flags
# Indicates whether or not to generate ld flags in addition to compile flags # Indicates whether or not to generate ld flags in addition to compile flags
# #
# @param [Boolean] test_xcconfig
# Whether the settings for dependent targets are being generated for a test xcconfig or not.
#
# @return [void] # @return [void]
# #
def self.add_settings_for_file_accessors_of_target(target, pod_target, xcconfig, include_ld_flags = true) def self.add_settings_for_file_accessors_of_target(target, pod_target, xcconfig, include_ld_flags = true, test_xcconfig = false)
pod_target.file_accessors.each do |file_accessor| file_accessors = pod_target.file_accessors
file_accessors = file_accessors.reject { |f| f.spec.test_specification? } unless test_xcconfig
file_accessors.each do |file_accessor|
if target.nil? || !file_accessor.spec.test_specification? if target.nil? || !file_accessor.spec.test_specification?
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig) if include_ld_flags XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig) if include_ld_flags
XCConfigHelper.add_static_dependency_build_settings(target, pod_target, xcconfig, file_accessor, include_ld_flags) XCConfigHelper.add_static_dependency_build_settings(target, pod_target, xcconfig, file_accessor, include_ld_flags)
end end
end end
XCConfigHelper.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags) XCConfigHelper.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags, test_xcconfig)
if pod_target.requires_frameworks? if pod_target.requires_frameworks?
pod_target.dependent_targets.each do |dependent_target| pod_target.dependent_targets.each do |dependent_target|
XCConfigHelper.add_dynamic_dependency_build_settings(target, dependent_target, xcconfig, include_ld_flags) XCConfigHelper.add_dynamic_dependency_build_settings(target, dependent_target, xcconfig, include_ld_flags, test_xcconfig)
end end
end end
end end
...@@ -153,10 +158,15 @@ module Pod ...@@ -153,10 +158,15 @@ module Pod
# @param [Boolean] include_ld_flags # @param [Boolean] include_ld_flags
# Indicates whether or not to generate ld flags in addition to compile flags # Indicates whether or not to generate ld flags in addition to compile flags
# #
# @param [Boolean] test_xcconfig
# Whether the settings for dependent targets are being generated for a test xcconfig or not.
#
# @return [void] # @return [void]
# #
def self.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags) def self.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags, test_xcconfig)
pod_target.file_accessors.each do |file_accessor| file_accessors = pod_target.file_accessors
file_accessors = file_accessors.reject { |f| f.spec.test_specification? } unless test_xcconfig
file_accessors.each do |file_accessor|
if target.nil? || !file_accessor.spec.test_specification? if target.nil? || !file_accessor.spec.test_specification?
file_accessor.vendored_dynamic_frameworks.each do |vendored_dynamic_framework| file_accessor.vendored_dynamic_frameworks.each do |vendored_dynamic_framework|
XCConfigHelper.add_framework_build_settings(vendored_dynamic_framework, xcconfig, pod_target.sandbox.root, include_ld_flags) XCConfigHelper.add_framework_build_settings(vendored_dynamic_framework, xcconfig, pod_target.sandbox.root, include_ld_flags)
...@@ -376,16 +386,19 @@ module Pod ...@@ -376,16 +386,19 @@ module Pod
# @param [Boolean] include_ld_flags # @param [Boolean] include_ld_flags
# Indicates whether or not to generate ld flags in addition to compile flags # Indicates whether or not to generate ld flags in addition to compile flags
# #
# @param [Boolean] test_xcconfig
# Indicates whether or not the generated ld flags are for a test xcconfig or not
#
# @note # @note
# In case of generated pod targets, which require frameworks, the # In case of generated pod targets, which require frameworks, the
# vendored frameworks and libraries are already linked statically # vendored frameworks and libraries are already linked statically
# into the framework binary and must not be linked again to the # into the framework binary and must not be linked again to the
# user target. # user target.
# #
def self.generate_vendored_build_settings(target, dep_targets, xcconfig, include_ld_flags = true) def self.generate_vendored_build_settings(target, dep_targets, xcconfig, include_ld_flags = true, test_xcconfig = false)
dep_targets.each do |dep_target| dep_targets.each do |dep_target|
unless dep_target.should_build? && dep_target.requires_frameworks? && !dep_target.static_framework? unless dep_target.should_build? && dep_target.requires_frameworks? && !dep_target.static_framework?
XCConfigHelper.add_settings_for_file_accessors_of_target(target, dep_target, xcconfig, include_ld_flags) XCConfigHelper.add_settings_for_file_accessors_of_target(target, dep_target, xcconfig, include_ld_flags, test_xcconfig)
end end
end end
end end
......
...@@ -442,6 +442,51 @@ module Pod ...@@ -442,6 +442,51 @@ module Pod
xcconfig.to_hash['OTHER_LDFLAGS'].should.be.nil xcconfig.to_hash['OTHER_LDFLAGS'].should.be.nil
end end
it 'propagates correct frameworks or libraries to both test and non test xcconfigs' do
spec = stub(:test_specification? => false)
consumer = stub(
:libraries => [],
:frameworks => [],
:weak_frameworks => [],
:spec => spec,
)
file_accessor = stub(
:spec => spec,
:spec_consumer => consumer,
:vendored_static_frameworks => [config.sandbox.root + 'StaticFramework.framework'],
:vendored_static_libraries => [config.sandbox.root + 'StaticLibrary.a'],
:vendored_dynamic_frameworks => [config.sandbox.root + 'VendoredFramework.framework'],
:vendored_dynamic_libraries => [config.sandbox.root + 'VendoredDyld.dyld'],
)
test_spec = stub(:test_specification? => true)
test_consumer = stub(
:libraries => ['xml2'],
:frameworks => ['XCTest'],
:weak_frameworks => [],
:spec => test_spec,
)
test_file_accessor = stub(
:spec => test_spec,
:spec_consumer => test_consumer,
:vendored_static_frameworks => [],
:vendored_static_libraries => [],
:vendored_dynamic_frameworks => [],
:vendored_dynamic_libraries => [],
)
pod_target = stub(
:file_accessors => [file_accessor, test_file_accessor],
:requires_frameworks? => true,
:dependent_targets => [],
:sandbox => config.sandbox,
)
xcconfig = Xcodeproj::Config.new
@sut.add_settings_for_file_accessors_of_target(nil, pod_target, xcconfig, true, false)
xcconfig.to_hash['OTHER_LDFLAGS'].should == '-l"StaticLibrary" -l"VendoredDyld" -framework "StaticFramework" -framework "VendoredFramework"'
test_xcconfig = Xcodeproj::Config.new
@sut.add_settings_for_file_accessors_of_target(nil, pod_target, test_xcconfig, true, true)
test_xcconfig.to_hash['OTHER_LDFLAGS'].should == '-l"StaticLibrary" -l"VendoredDyld" -l"xml2" -framework "StaticFramework" -framework "VendoredFramework" -framework "XCTest"'
end
it 'does propagate framework or libraries from a non test specification to an aggregate target' do it 'does propagate framework or libraries from a non test specification to an aggregate target' do
spec = stub(:test_specification? => false) spec = stub(:test_specification? => false)
consumer = stub( consumer = stub(
......
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