Unverified Commit b6309bbd authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7445 from dnkoutso/fix_legacy_header_paths

Fix legacy header search paths
parents d16f648e b1035d46
......@@ -87,6 +87,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
instead of via the sandbox headers store.
[Samuel Giddins](https://github.com/segiddins)
* Fix legacy header search paths that broke due to #7116 and #7412.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7445](https://github.com/CocoaPods/CocoaPods/pull/7445)
## 1.4.0 (2018-01-18)
......
......@@ -602,10 +602,16 @@ module Pod
header_search_paths = []
header_search_paths.concat(build_headers.search_paths(platform, nil, uses_modular_headers?))
header_search_paths.concat(sandbox.public_headers.search_paths(platform, pod_name, uses_modular_headers?))
dependent_targets = recursive_dependent_targets
dependent_targets += recursive_test_dependent_targets if include_test_dependent_targets
dependent_targets.each do |dependent_target|
header_search_paths.concat(sandbox.public_headers.search_paths(platform, dependent_target.pod_name, defines_module? && dependent_target.uses_modular_headers?(false)))
# Modular headers will only provide header search paths of the dependencies of the pod target. That is in
# contrast to legacy mode, which has always given access to all pods header search paths.
if uses_modular_headers?
dependent_targets = recursive_dependent_targets
dependent_targets += recursive_test_dependent_targets if include_test_dependent_targets
dependent_targets.each do |dependent_target|
header_search_paths.concat(sandbox.public_headers.search_paths(platform, dependent_target.pod_name, defines_module? && dependent_target.uses_modular_headers?(false)))
end
else
header_search_paths.concat(sandbox.public_headers.search_paths(platform))
end
header_search_paths.uniq
end
......
Subproject commit 5e83e892038cab89896eba2beb266d831a7318ea
Subproject commit 21bf4969be6345e4761a3cca3e91e8a3b953a302
......@@ -259,11 +259,13 @@ module Pod
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
it 'adds correct header search paths for dependent and test targets' do
it 'adds correct header search paths for dependent and test targets without modular headers' do
@monkey_pod_target.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@banana_pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@banana_pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@coconut_pod_target.stubs(:uses_modular_headers?).returns(false)
@coconut_pod_target.stubs(:defines_module?).returns(false)
@coconut_pod_target.build_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.sandbox.public_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.test_dependent_targets = [@monkey_pod_target]
......@@ -276,11 +278,13 @@ module Pod
' "${PODS_ROOT}/Headers/Public/monkey" "${PODS_ROOT}/Headers/Public/monkey/monkey"'
end
it 'adds correct header search paths for dependent and test targets for non test xcconfigs' do
it 'adds correct header search paths for dependent and test targets for non test xcconfigs without modular headers' do
@monkey_pod_target.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@banana_pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@banana_pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@coconut_pod_target.stubs(:uses_modular_headers?).returns(false)
@coconut_pod_target.stubs(:defines_module?).returns(false)
@coconut_pod_target.build_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.sandbox.public_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.test_dependent_targets = [@monkey_pod_target]
......@@ -290,7 +294,45 @@ module Pod
xcconfig = generator.generate
xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/Headers/Private/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public/BananaLib" "${PODS_ROOT}/Headers/Public/BananaLib/BananaLib"' \
' "${PODS_ROOT}/Headers/Public/CoconutLib" "${PODS_ROOT}/Headers/Public/CoconutLib/CoconutLib"'
' "${PODS_ROOT}/Headers/Public/CoconutLib" "${PODS_ROOT}/Headers/Public/CoconutLib/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public/monkey" "${PODS_ROOT}/Headers/Public/monkey/monkey"'
end
it 'adds correct header search paths for dependent and test targets with modular headers' do
@monkey_pod_target.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@banana_pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@banana_pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@coconut_pod_target.stubs(:uses_modular_headers?).returns(true)
@coconut_pod_target.stubs(:defines_module?).returns(true)
@coconut_pod_target.build_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.sandbox.public_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.test_dependent_targets = [@monkey_pod_target]
@coconut_pod_target.dependent_targets = [@banana_pod_target]
generator = PodXCConfig.new(@coconut_pod_target, true)
xcconfig = generator.generate
xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/Headers/Private/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public/BananaLib"' \
' "${PODS_ROOT}/Headers/Public/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public/monkey"'
end
it 'adds correct header search paths for dependent and test targets for non test xcconfigs with modular headers' do
@monkey_pod_target.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@banana_pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@banana_pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@coconut_pod_target.stubs(:uses_modular_headers?).returns(true)
@coconut_pod_target.stubs(:defines_module?).returns(true)
@coconut_pod_target.build_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.sandbox.public_headers.add_search_path('CoconutLib', Platform.ios)
@coconut_pod_target.test_dependent_targets = [@monkey_pod_target]
@coconut_pod_target.dependent_targets = [@banana_pod_target]
generator = PodXCConfig.new(@coconut_pod_target, false)
xcconfig = generator.generate
xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/Headers/Private/CoconutLib"' \
' "${PODS_ROOT}/Headers/Public/BananaLib"' \
' "${PODS_ROOT}/Headers/Public/CoconutLib"' \
end
it 'does not include other ld flags for test dependent targets if its not a test xcconfig' do
......
......@@ -280,6 +280,31 @@ module Pod
'${PODS_ROOT}/Headers/Public/BananaLib/BananaLib',
]
end
# This is a legacy header search paths test support that adds header search paths for all dependencies
# even the ones that are not part of the podspec. It is how CocoaPods always worked until support for modular
# header search paths support was added in > 1.4.0
it 'includes header search paths for all dependent targets' do
@pod_target.build_headers.add_search_path('BananaLib', Platform.ios)
@pod_target.sandbox.public_headers.add_search_path('BananaLib', Platform.ios)
@pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
@pod_target.sandbox.public_headers.add_search_path('matryoshka', Platform.ios)
monkey_spec = fixture_spec('monkey/monkey.podspec')
monkey_pod_target = PodTarget.new([monkey_spec], [@target_definition], config.sandbox)
monkey_pod_target.stubs(:platform).returns(Platform.ios)
# Notice that pod target does not depend on `matryoshka` but it will still include its header search paths
@pod_target.stubs(:dependent_targets).returns([monkey_pod_target])
header_search_paths = @pod_target.header_search_paths
header_search_paths.sort.should == [
'${PODS_ROOT}/Headers/Private/BananaLib',
'${PODS_ROOT}/Headers/Public/BananaLib',
'${PODS_ROOT}/Headers/Public/BananaLib/BananaLib',
'${PODS_ROOT}/Headers/Public/matryoshka',
'${PODS_ROOT}/Headers/Public/matryoshka/matryoshka',
'${PODS_ROOT}/Headers/Public/monkey',
'${PODS_ROOT}/Headers/Public/monkey/monkey',
]
end
end
describe 'modular header search paths' 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