Fix to include proper runtime search paths for test native targets

parent 80334c51
...@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements ##### Enhancements
* Fix to include proper runtime search paths for test native targets
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6727](https://github.com/CocoaPods/CocoaPods/pull/6727)
* Add support for test target creation in the pods project generator * Add support for test target creation in the pods project generator
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6703](https://github.com/CocoaPods/CocoaPods/pull/6703) [#6703](https://github.com/CocoaPods/CocoaPods/pull/6703)
......
...@@ -85,7 +85,9 @@ module Pod ...@@ -85,7 +85,9 @@ module Pod
# update the runpath search paths. # update the runpath search paths.
vendored_dynamic_artifacts = pod_targets.flat_map(&:file_accessors).flat_map(&:vendored_dynamic_artifacts) vendored_dynamic_artifacts = pod_targets.flat_map(&:file_accessors).flat_map(&:vendored_dynamic_artifacts)
generate_ld_runpath_search_paths if target.requires_frameworks? || vendored_dynamic_artifacts.count > 0 symbol_type = target.user_targets.map(&:symbol_type).uniq.first
test_bundle = symbol_type == :octest_bundle || symbol_type == :unit_test_bundle || symbol_type == :ui_test_bundle
XCConfigHelper.generate_ld_runpath_search_paths(target, target.requires_host_target?, test_bundle, @xcconfig) if target.requires_frameworks? || vendored_dynamic_artifacts.count > 0
@xcconfig @xcconfig
end end
...@@ -177,35 +179,6 @@ module Pod ...@@ -177,35 +179,6 @@ module Pod
end end
end end
# Ensure to add the default linker run path search paths as they could
# be not present due to being historically absent in the project or
# target template or just being removed by being superficial when
# linking third-party dependencies exclusively statically. This is not
# something a project needs specifically for the integration with
# CocoaPods, but makes sure that it is self-contained for the given
# constraints.
#
def generate_ld_runpath_search_paths
ld_runpath_search_paths = ['$(inherited)']
if target.platform.symbolic_name == :osx
ld_runpath_search_paths << "'@executable_path/../Frameworks'"
symbol_type = target.user_targets.map(&:symbol_type).uniq.first
ld_runpath_search_paths << \
if symbol_type == :unit_test_bundle
"'@loader_path/../Frameworks'"
else
"'@loader_path/Frameworks'"
end
else
ld_runpath_search_paths << [
"'@executable_path/Frameworks'",
"'@loader_path/Frameworks'",
]
ld_runpath_search_paths << "'@executable_path/../../Frameworks'" if target.requires_host_target?
end
@xcconfig.merge!('LD_RUNPATH_SEARCH_PATHS' => ld_runpath_search_paths.join(' '))
end
private private
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
......
...@@ -74,6 +74,7 @@ module Pod ...@@ -74,6 +74,7 @@ module Pod
@xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, target.test_dependent_targets) @xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, target.test_dependent_targets)
XCConfigHelper.generate_vendored_build_settings(nil, target.test_dependent_targets, @xcconfig) XCConfigHelper.generate_vendored_build_settings(nil, target.test_dependent_targets, @xcconfig)
XCConfigHelper.generate_other_ld_flags(nil, target.test_dependent_targets, @xcconfig) XCConfigHelper.generate_other_ld_flags(nil, target.test_dependent_targets, @xcconfig)
XCConfigHelper.generate_ld_runpath_search_paths(target, false, true, @xcconfig)
end end
@xcconfig @xcconfig
end end
......
...@@ -324,6 +324,49 @@ module Pod ...@@ -324,6 +324,49 @@ module Pod
end end
end end
# Ensure to add the default linker run path search paths as they could
# be not present due to being historically absent in the project or
# target template or just being removed by being superficial when
# linking third-party dependencies exclusively statically. This is not
# something a project needs specifically for the integration with
# CocoaPods, but makes sure that it is self-contained for the given
# constraints.
#
# @param [Target] target
# The target, this can be an aggregate target or a pod target.
#
# @param [Boolean] requires_host_target
# If this target requires a host target
#
# @param [Boolean] test_bundle
# Whether this is a test bundle or not. This has an effect when the platform is `osx` and changes
# the runtime search paths accordingly.
#
# @param [Xcodeproj::Config] xcconfig
# The xcconfig to edit.
#
# @return [void]
#
def self.generate_ld_runpath_search_paths(target, requires_host_target, test_bundle, xcconfig)
ld_runpath_search_paths = ['$(inherited)']
if target.platform.symbolic_name == :osx
ld_runpath_search_paths << "'@executable_path/../Frameworks'"
ld_runpath_search_paths << \
if test_bundle
"'@loader_path/../Frameworks'"
else
"'@loader_path/Frameworks'"
end
else
ld_runpath_search_paths << [
"'@executable_path/Frameworks'",
"'@loader_path/Frameworks'",
]
ld_runpath_search_paths << "'@executable_path/../../Frameworks'" if requires_host_target
end
xcconfig.merge!('LD_RUNPATH_SEARCH_PATHS' => ld_runpath_search_paths.join(' '))
end
# Add pod target to list of frameworks / libraries that are linked # Add pod target to list of frameworks / libraries that are linked
# with the user’s project. # with the user’s project.
# #
......
...@@ -169,6 +169,19 @@ module Pod ...@@ -169,6 +169,19 @@ module Pod
xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should.be.nil xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should.be.nil
xcconfig.to_hash['OTHER_LDFLAGS'].should.be.nil xcconfig.to_hash['OTHER_LDFLAGS'].should.be.nil
end end
it 'includes default runpath search path list for test xcconfigs' do
generator = PodXCConfig.new(@coconut_pod_target, true)
xcconfig = generator.generate
xcconfig.to_hash['LD_RUNPATH_SEARCH_PATHS'].should == "$(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'"
end
it 'includes default runpath search path list for test xcconfigs for test bundle' do
@coconut_pod_target.stubs(:platform).returns(Platform.new(:osx, '10.10'))
generator = PodXCConfig.new(@coconut_pod_target, true)
xcconfig = generator.generate
xcconfig.to_hash['LD_RUNPATH_SEARCH_PATHS'].should == "$(inherited) '@executable_path/../Frameworks' '@loader_path/../Frameworks'"
end
end end
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