Unverified Commit d16f648e authored by Samuel Giddins's avatar Samuel Giddins Committed by GitHub

Merge pull request #7442 from CocoaPods/seg-vendored-frameworks-no-sandbox-headers

Use FRAMEWORK_SEARCH_PATHS to discover headers of vendored frameworks
parents d7c0b2b3 a5374c3d
...@@ -82,6 +82,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -82,6 +82,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
* Avoid dependency resolution conflicts when a pod depends upon a local pod. * Avoid dependency resolution conflicts when a pod depends upon a local pod.
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
* When integrating a vendored framework while building pods as static
libraries, public headers will be found via `FRAMEWORK_SEARCH_PATHS`
instead of via the sandbox headers store.
[Samuel Giddins](https://github.com/segiddins)
## 1.4.0 (2018-01-18) ## 1.4.0 (2018-01-18)
......
...@@ -90,9 +90,11 @@ module Pod ...@@ -90,9 +90,11 @@ module Pod
end end
end end
XCConfigHelper.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags, test_xcconfig) XCConfigHelper.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags, test_xcconfig)
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, test_xcconfig) XCConfigHelper.add_dynamic_dependency_build_settings(target, dependent_target, xcconfig, include_ld_flags, test_xcconfig)
dependent_target.file_accessors.each do |file_accessor|
XCConfigHelper.add_static_dependency_build_settings(target, dependent_target, xcconfig, file_accessor, false)
end end
end end
end end
......
...@@ -136,39 +136,32 @@ module Pod ...@@ -136,39 +136,32 @@ module Pod
UI.message '- Linking headers' do UI.message '- Linking headers' do
pod_targets.each do |pod_target| pod_targets.each do |pod_target|
pod_target.file_accessors.each do |file_accessor| pod_target.file_accessors.each do |file_accessor|
framework_exp = /\.framework\//
headers_sandbox = Pathname.new(file_accessor.spec.root.name)
# When integrating Pod as frameworks, built Pods are built into # When integrating Pod as frameworks, built Pods are built into
# frameworks, whose headers are included inside the built # frameworks, whose headers are included inside the built
# framework. Those headers do not need to be linked from the # framework. Those headers do not need to be linked from the
# sandbox. # sandbox.
unless pod_target.requires_frameworks? && pod_target.should_build? next if pod_target.requires_frameworks? || !pod_target.should_build?
headers_sandbox = Pathname.new(file_accessor.spec.root.name)
pod_target.build_headers.add_search_path(headers_sandbox, pod_target.platform) pod_target.build_headers.add_search_path(headers_sandbox, pod_target.platform)
sandbox.public_headers.add_search_path(headers_sandbox, pod_target.platform) sandbox.public_headers.add_search_path(headers_sandbox, pod_target.platform)
# Private headers will always end up in Pods/Headers/Private/PodA/*.h # Private headers will always end up in Pods/Headers/Private/PodA/*.h
# This will allow for `""` imports to work. # This will allow for `""` imports to work.
header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files| header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
pod_target.build_headers.add_files(namespaced_path, files.reject { |f| f.to_path =~ framework_exp }) pod_target.build_headers.add_files(namespaced_path, files)
end end
# Public headers on the other hand will be added in Pods/Headers/Public/PodA/PodA/*.h # Public headers on the other hand will be added in Pods/Headers/Public/PodA/PodA/*.h
# The extra folder is intentional in order for `<>` imports to work. # The extra folder is intentional in order for `<>` imports to work.
header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers, :public).each do |namespaced_path, files| header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers, :public).each do |namespaced_path, files|
sandbox.public_headers.add_files(namespaced_path, files.reject { |f| f.to_path =~ framework_exp })
end
end
unless pod_target.requires_frameworks?
vendored_frameworks_header_mappings(headers_sandbox, file_accessor).each do |namespaced_path, files|
sandbox.public_headers.add_files(namespaced_path, files) sandbox.public_headers.add_files(namespaced_path, files)
end end
end end
end end
end end
end end
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -319,6 +312,8 @@ module Pod ...@@ -319,6 +312,8 @@ module Pod
mappings = {} mappings = {}
headers.each do |header| headers.each do |header|
next if header.to_s.include?('.framework/')
sub_dir = dir sub_dir = dir
if header_mappings_dir if header_mappings_dir
relative_path = header.relative_path_from(file_accessor.path_list.root + header_mappings_dir) relative_path = header.relative_path_from(file_accessor.path_list.root + header_mappings_dir)
...@@ -330,36 +325,6 @@ module Pod ...@@ -330,36 +325,6 @@ module Pod
mappings mappings
end end
# Computes the destination sub-directory in the sandbox for headers
# from inside vendored frameworks.
#
# @param [Pathname] headers_sandbox
# The sandbox where the header links should be stored for this
# Pod.
#
# @param [Sandbox::FileAccessor] file_accessor
# The consumer file accessor for which the headers need to be
# linked.
#
def vendored_frameworks_header_mappings(headers_sandbox, file_accessor)
mappings = {}
file_accessor.vendored_frameworks.each do |framework|
headers_dir = Sandbox::FileAccessor.vendored_frameworks_headers_dir(framework)
headers = Sandbox::FileAccessor.vendored_frameworks_headers(framework)
framework_name = framework.basename(framework.extname)
dir = headers_sandbox + framework_name
headers.each do |header|
# the relative path of framework headers should be kept,
# not flattened like is done for most public headers.
relative_path = header.relative_path_from(headers_dir)
sub_dir = dir + relative_path.dirname
mappings[sub_dir] ||= []
mappings[sub_dir] << header
end
end
mappings
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
......
Subproject commit ce9fcea6cbeb3d1f2cdc000c204569182cce92b9 Subproject commit 5e83e892038cab89896eba2beb266d831a7318ea
...@@ -115,12 +115,12 @@ module Pod ...@@ -115,12 +115,12 @@ module Pod
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('${PODS_ROOT}/DDD') @xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('${PODS_ROOT}/DDD')
end end
it 'vendored frameworks dont get added to frameworks paths if use_frameworks! isnt set' do it 'vendored frameworks get added to frameworks paths even if use_frameworks! isnt set' do
@pod_target.stubs(:requires_frameworks?).returns(false) @pod_target.stubs(:requires_frameworks?).returns(false)
@xcconfig = @generator.generate @xcconfig = @generator.generate
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('spec/fixtures/monkey') @xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('spec/fixtures/monkey')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('${PODS_ROOT}/AAA') @xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('${PODS_ROOT}/AAA')
@xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('${PODS_ROOT}/CCC') @xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('${PODS_ROOT}/CCC')
end end
it 'sets the PODS_ROOT build variable' do it 'sets the PODS_ROOT build variable' do
...@@ -256,7 +256,7 @@ module Pod ...@@ -256,7 +256,7 @@ module Pod
generator = PodXCConfig.new(@coconut_pod_target, true) generator = PodXCConfig.new(@coconut_pod_target, true)
xcconfig = generator.generate xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib"' xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should == '$(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/BananaLib" "${PODS_CONFIGURATION_BUILD_DIR}/CoconutLib" "${PODS_ROOT}/../../spec/fixtures/banana-lib"' xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib" "${PODS_CONFIGURATION_BUILD_DIR}/BananaLib" "${PODS_CONFIGURATION_BUILD_DIR}/CoconutLib"'
end end
it 'adds correct header search paths for dependent and test targets' do it 'adds correct header search paths for dependent and test targets' do
......
...@@ -115,7 +115,7 @@ module Pod ...@@ -115,7 +115,7 @@ module Pod
config.verbose = true config.verbose = true
@hooks_manager.register('plugin', :post_install) {} @hooks_manager.register('plugin', :post_install) {}
@hooks_manager.run(:post_install, Object.new) @hooks_manager.run(:post_install, Object.new)
UI.output.should.match %r{- plugin from `spec/unit/hooks_manager_spec.rb`} UI.output.should.include "- plugin from `#{__FILE__}`"
end end
end end
end end
......
...@@ -90,11 +90,11 @@ module Pod ...@@ -90,11 +90,11 @@ module Pod
framework_subdir_header = headers_root + 'BananaLib/Bananalib/SubDir/SubBananalib.h' framework_subdir_header = headers_root + 'BananaLib/Bananalib/SubDir/SubBananalib.h'
public_headers.each { |public_header| public_header.should.exist } public_headers.each { |public_header| public_header.should.exist }
private_header.should.not.exist private_header.should.not.exist
framework_header.should.exist framework_header.should.not.exist
framework_subdir_header.should.exist framework_subdir_header.should.not.exist
end end
it 'links the public headers meant for the user, but only for Pods that are not built' do it 'does not link the public headers meant for the user for a vendored framework' do
Target.any_instance.stubs(:requires_frameworks?).returns(true) Target.any_instance.stubs(:requires_frameworks?).returns(true)
pod_target_one = fixture_pod_target('banana-lib/BananaLib.podspec') pod_target_one = fixture_pod_target('banana-lib/BananaLib.podspec')
pod_target_two = fixture_pod_target('monkey/monkey.podspec') pod_target_two = fixture_pod_target('monkey/monkey.podspec')
...@@ -107,7 +107,7 @@ module Pod ...@@ -107,7 +107,7 @@ module Pod
banana_headers = [headers_root + 'BananaLib/Banana.h', headers_root + 'BananaLib/MoreBanana.h'] banana_headers = [headers_root + 'BananaLib/Banana.h', headers_root + 'BananaLib/MoreBanana.h']
banana_headers.each { |banana_header| banana_header.should.not.exist } banana_headers.each { |banana_header| banana_header.should.not.exist }
monkey_header = headers_root + 'monkey/monkey/monkey.h' monkey_header = headers_root + 'monkey/monkey/monkey.h'
monkey_header.should.exist monkey_header.should.not.exist
end end
it "doesn't link public headers from vendored framework, when frameworks required" do it "doesn't link public headers from vendored framework, when frameworks required" do
...@@ -301,19 +301,6 @@ module Pod ...@@ -301,19 +301,6 @@ module Pod
result.should.be.nil result.should.be.nil
end end
end end
describe '#vendored_frameworks_header_mappings' do
it 'returns the vendored frameworks header mappings' do
headers_sandbox = Pathname.new('BananaLib')
header = @file_accessor.root + 'Bananalib.framework/Versions/A/Headers/Bananalib.h'
header_subdir = @file_accessor.root + 'Bananalib.framework/Versions/A/Headers/SubDir/SubBananalib.h'
mappings = @installer.send(:vendored_frameworks_header_mappings, headers_sandbox, @file_accessor)
mappings.should == {
(headers_sandbox + 'Bananalib') => [header],
(headers_sandbox + 'Bananalib/SubDir') => [header_subdir],
}
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