Commit 32d37754 authored by Samuel Giddins's avatar Samuel Giddins

[BuildSettings] Ensure the framework search path for XCTest is added for static…

[BuildSettings] Ensure the framework search path for XCTest is added for static library pods that depend on it
parent 8c2d9d13
...@@ -97,6 +97,10 @@ module Pod ...@@ -97,6 +97,10 @@ module Pod
end end
define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true do define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true do
framework_search_paths_to_import_developer_frameworks(frameworks)
end
def framework_search_paths_to_import_developer_frameworks(frameworks)
if frameworks.include?('XCTest') || frameworks.include?('SenTestingKit') if frameworks.include?('XCTest') || frameworks.include?('SenTestingKit')
%w[ $(PLATFORM_DIR)/Developer/Library/Frameworks ] %w[ $(PLATFORM_DIR)/Developer/Library/Frameworks ]
else else
...@@ -249,11 +253,15 @@ module Pod ...@@ -249,11 +253,15 @@ module Pod
dependent_targets.each { |pt| pt.build_settings.__clear__ } dependent_targets.each { |pt| pt.build_settings.__clear__ }
end end
define_build_settings_method :consumer_frameworks, :memoized => true do
spec_consumers.flat_map(&:frameworks)
end
define_build_settings_method :frameworks, :memoized => true, :sorted => true, :uniqued => true do define_build_settings_method :frameworks, :memoized => true, :sorted => true, :uniqued => true do
return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig? return [] if (!target.requires_frameworks? || target.static_framework?) && !test_xcconfig?
frameworks = vendored_dynamic_frameworks.map { |l| File.basename(l, '.framework') } frameworks = vendored_dynamic_frameworks.map { |l| File.basename(l, '.framework') }
frameworks.concat spec_consumers.flat_map(&:frameworks) frameworks.concat consumer_frameworks
frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.dynamic_frameworks_to_import } frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.dynamic_frameworks_to_import }
frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.static_frameworks_to_import } if test_xcconfig? frameworks.concat dependent_targets.flat_map { |pt| pt.build_settings.static_frameworks_to_import } if test_xcconfig?
frameworks.tap(&:uniq!).tap(&:sort!) frameworks.tap(&:uniq!).tap(&:sort!)
...@@ -268,7 +276,7 @@ module Pod ...@@ -268,7 +276,7 @@ module Pod
define_build_settings_method :dynamic_frameworks_to_import, :memoized => true do define_build_settings_method :dynamic_frameworks_to_import, :memoized => true do
dynamic_frameworks_to_import = vendored_dynamic_frameworks.map { |f| File.basename(f, '.framework') } dynamic_frameworks_to_import = vendored_dynamic_frameworks.map { |f| File.basename(f, '.framework') }
dynamic_frameworks_to_import << target.product_basename if target.should_build? && target.requires_frameworks? && !target.static_framework? dynamic_frameworks_to_import << target.product_basename if target.should_build? && target.requires_frameworks? && !target.static_framework?
dynamic_frameworks_to_import.concat spec_consumers.flat_map(&:frameworks) dynamic_frameworks_to_import.concat consumer_frameworks
dynamic_frameworks_to_import dynamic_frameworks_to_import
end end
...@@ -391,12 +399,8 @@ module Pod ...@@ -391,12 +399,8 @@ module Pod
define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do define_build_settings_method :framework_search_paths, :build_setting => true, :memoized => true, :sorted => true, :uniqued => true do
paths = super().dup paths = super().dup
paths.concat dependent_targets.flat_map { |t| t.build_settings.framework_search_paths_to_import } paths.concat dependent_targets.flat_map { |t| t.build_settings.framework_search_paths_to_import }
if test_xcconfig? paths.concat framework_search_paths_to_import
paths.concat framework_search_paths_to_import paths.delete(target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)) unless test_xcconfig?
else
paths.concat vendored_framework_search_paths
paths.delete(target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE))
end
paths paths
end end
...@@ -405,9 +409,11 @@ module Pod ...@@ -405,9 +409,11 @@ module Pod
end end
define_build_settings_method :framework_search_paths_to_import, :memoized => true do define_build_settings_method :framework_search_paths_to_import, :memoized => true do
return vendored_framework_search_paths unless target.requires_frameworks? && target.should_build? paths = framework_search_paths_to_import_developer_frameworks(consumer_frameworks)
paths.concat vendored_framework_search_paths
return paths unless target.requires_frameworks? && target.should_build?
vendored_framework_search_paths + [target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)] paths + [target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)]
end end
define_build_settings_method :other_swift_flags, :build_setting => true, :memoized => true do define_build_settings_method :other_swift_flags, :build_setting => true, :memoized => true do
......
...@@ -298,6 +298,19 @@ module Pod ...@@ -298,6 +298,19 @@ module Pod
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_CONFIGURATION_BUILD_DIR}/BananaLib" "${PODS_CONFIGURATION_BUILD_DIR}/CoconutLib" "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
end end
it 'adds the developer frameworks dir when XCTest is used but not linked' do
@banana_pod_target.spec_consumers.each { |sc| sc.stubs(:frameworks => %w(XCTest), :vendored_frameworks => []) }
@coconut_pod_target.dependent_targets = [@banana_pod_target]
generator = Pod.new(@coconut_pod_target, false)
xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
generator = Pod.new(@banana_pod_target, false)
xcconfig = generator.generate
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
end
it 'adds correct header search paths for dependent and test targets without modular headers' 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.build_headers.add_search_path('monkey', Platform.ios)
@monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios) @monkey_pod_target.sandbox.public_headers.add_search_path('monkey', Platform.ios)
......
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