Commit 5f39a708 authored by Danielle Tomlinson's avatar Danielle Tomlinson Committed by GitHub

Merge pull request #6886 from dnkoutso/resoure_bundles_xcconfig

Set the test xcconfig file to resource bundles used only by tests
parents a7c892ea 3dc326e8
...@@ -27,6 +27,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -27,6 +27,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes ##### Bug Fixes
* Set the test xcconfig file to resource bundles used only by tests
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6886](https://github.com/CocoaPods/CocoaPods/pull/6886)
* Integrate test targets to embed frameworks and resources * Integrate test targets to embed frameworks and resources
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6828](https://github.com/CocoaPods/CocoaPods/pull/6828) [#6828](https://github.com/CocoaPods/CocoaPods/pull/6828)
......
...@@ -280,7 +280,7 @@ module Pod ...@@ -280,7 +280,7 @@ module Pod
CONFIGURATION_BUILD_DIR_VARIABLE[1..-1] => "#{BUILD_DIR_VARIABLE}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)", CONFIGURATION_BUILD_DIR_VARIABLE[1..-1] => "#{BUILD_DIR_VARIABLE}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)",
} }
# Scope pod targets # Scope pod targets as long as they are not test targets.
if !test_xcconfig && target.respond_to?(:configuration_build_dir) if !test_xcconfig && target.respond_to?(:configuration_build_dir)
build_settings['CONFIGURATION_BUILD_DIR'] = target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE) build_settings['CONFIGURATION_BUILD_DIR'] = target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
end end
......
...@@ -290,7 +290,8 @@ module Pod ...@@ -290,7 +290,8 @@ module Pod
end end
def add_resource_bundles_to_native_target(dependent_target, native_target) def add_resource_bundles_to_native_target(dependent_target, native_target)
dependent_target.resource_bundle_targets.each do |resource_bundle_target| resource_bundle_targets = dependent_target.resource_bundle_targets + dependent_target.test_resource_bundle_targets
resource_bundle_targets.each do |resource_bundle_target|
native_target.add_dependency(resource_bundle_target) native_target.add_dependency(resource_bundle_target)
end end
end end
......
...@@ -234,7 +234,13 @@ module Pod ...@@ -234,7 +234,13 @@ module Pod
end end
bundle_target.deployment_target = deployment_target bundle_target.deployment_target = deployment_target
test_specification = file_accessor.spec.test_specification?
if test_specification
target.test_resource_bundle_targets << bundle_target
else
target.resource_bundle_targets << bundle_target target.resource_bundle_targets << bundle_target
end
if target.should_build? if target.should_build?
native_target.add_dependency(bundle_target) native_target.add_dependency(bundle_target)
...@@ -255,7 +261,12 @@ module Pod ...@@ -255,7 +261,12 @@ module Pod
c.build_settings['PRODUCT_NAME'] = bundle_name c.build_settings['PRODUCT_NAME'] = bundle_name
relative_info_plist_path = info_plist_path.relative_path_from(sandbox.root) relative_info_plist_path = info_plist_path.relative_path_from(sandbox.root)
c.build_settings['INFOPLIST_FILE'] = relative_info_plist_path.to_s c.build_settings['INFOPLIST_FILE'] = relative_info_plist_path.to_s
# Do not set the CONFIGURATION_BUILD_DIR for resource bundles that are only meant for test targets.
# This is because the test target itself also does not set this configuration build dir and it expects
# all bundles to be copied from the default path.
unless test_specification
c.build_settings['CONFIGURATION_BUILD_DIR'] = target.configuration_build_dir('$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)') c.build_settings['CONFIGURATION_BUILD_DIR'] = target.configuration_build_dir('$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)')
end
# Set the correct device family for this bundle, based on the platform # Set the correct device family for this bundle, based on the platform
device_family_by_platform = { device_family_by_platform = {
...@@ -286,12 +297,8 @@ module Pod ...@@ -286,12 +297,8 @@ module Pod
c.base_configuration_reference = xcconfig_file_ref c.base_configuration_reference = xcconfig_file_ref
end end
# also apply the private config to resource targets # also apply the private config to resource bundle targets.
target.resource_bundle_targets.each do |rsrc_target| apply_xcconfig_file_ref_to_resource_bundle_targets(target.resource_bundle_targets, xcconfig_file_ref)
rsrc_target.build_configurations.each do |rsrc_bc|
rsrc_bc.base_configuration_reference = xcconfig_file_ref
end
end
end end
# Generates the contents of the xcconfig file used for each test target type and saves it to disk. # Generates the contents of the xcconfig file used for each test target type and saves it to disk.
...@@ -311,6 +318,9 @@ module Pod ...@@ -311,6 +318,9 @@ module Pod
test_target_bc.base_configuration_reference = xcconfig_file_ref test_target_bc.base_configuration_reference = xcconfig_file_ref
end end
end end
# also apply the private config to resource bundle test targets.
apply_xcconfig_file_ref_to_resource_bundle_targets(target.test_resource_bundle_targets, xcconfig_file_ref)
end end
end end
...@@ -469,6 +479,14 @@ module Pod ...@@ -469,6 +479,14 @@ module Pod
group.new_file(path) group.new_file(path)
end end
def apply_xcconfig_file_ref_to_resource_bundle_targets(resource_bundle_targets, xcconfig_file_ref)
resource_bundle_targets.each do |rsrc_target|
rsrc_target.build_configurations.each do |rsrc_bc|
rsrc_bc.base_configuration_reference = xcconfig_file_ref
end
end
end
def create_module_map def create_module_map
return super unless custom_module_map return super unless custom_module_map
path = target.module_map_path path = target.module_map_path
......
...@@ -56,6 +56,7 @@ module Pod ...@@ -56,6 +56,7 @@ module Pod
@build_headers = Sandbox::HeadersStore.new(sandbox, 'Private') @build_headers = Sandbox::HeadersStore.new(sandbox, 'Private')
@file_accessors = [] @file_accessors = []
@resource_bundle_targets = [] @resource_bundle_targets = []
@test_resource_bundle_targets = []
@test_native_targets = [] @test_native_targets = []
@dependent_targets = [] @dependent_targets = []
@test_dependent_targets = [] @test_dependent_targets = []
...@@ -149,6 +150,10 @@ module Pod ...@@ -149,6 +150,10 @@ module Pod
# to this target. # to this target.
attr_reader :resource_bundle_targets attr_reader :resource_bundle_targets
# @return [Array<PBXNativeTarget>] the resource bundle test targets belonging
# to this target.
attr_reader :test_resource_bundle_targets
# @return [Bool] Whether or not this target should be build. # @return [Bool] Whether or not this target should be build.
# #
# A target should not be build if it has no source files. # A target should not be build if it has no source files.
...@@ -231,7 +236,9 @@ module Pod ...@@ -231,7 +236,9 @@ module Pod
accessor.resources.flat_map { |res| "${PODS_ROOT}/#{res.relative_path_from(sandbox.project.path.dirname)}" } accessor.resources.flat_map { |res| "${PODS_ROOT}/#{res.relative_path_from(sandbox.project.path.dirname)}" }
end end
resource_bundles = file_accessors.flat_map do |accessor| resource_bundles = file_accessors.flat_map do |accessor|
accessor.resource_bundles.keys.map { |name| "#{configuration_build_dir}/#{name.shellescape}.bundle" } prefix = Generator::XCConfig::XCConfigHelper::CONFIGURATION_BUILD_DIR_VARIABLE
prefix = configuration_build_dir unless accessor.spec.test_specification?
accessor.resource_bundles.keys.map { |name| "#{prefix}/#{name.shellescape}.bundle" }
end end
resource_paths + resource_bundles resource_paths + resource_bundles
end end
......
...@@ -237,6 +237,18 @@ module Pod ...@@ -237,6 +237,18 @@ module Pod
content = @coconut_pod_target.umbrella_header_path.read content = @coconut_pod_target.umbrella_header_path.read
content.should.not =~ /"CoconutTestHeader.h"/ content.should.not =~ /"CoconutTestHeader.h"/
end end
it 'adds test xcconfig file reference for test resource bundle targets' do
@coconut_spec.test_specs.first.resource_bundle = { 'CoconutLibTestResources' => ['Model.xcdatamodeld'] }
@installer.install!
@coconut_pod_target.resource_bundle_targets.count.should == 0
@coconut_pod_target.test_resource_bundle_targets.count.should == 1
test_resource_bundle_target = @project.targets.find { |t| t.name == 'CoconutLib-CoconutLibTestResources' }
test_resource_bundle_target.build_configurations.each do |bc|
bc.base_configuration_reference.real_path.basename.to_s.should == 'CoconutLib.unit.xcconfig'
bc.build_settings['CONFIGURATION_BUILD_DIR'].should.be.nil
end
end
end end
describe 'test other files under sources' do describe 'test other files under sources' do
......
...@@ -366,6 +366,15 @@ module Pod ...@@ -366,6 +366,15 @@ module Pod
it 'returns correct embed frameworks script path for test unit test type' do it 'returns correct embed frameworks script path for test unit test type' do
@test_pod_target.embed_frameworks_script_path_for_test_type(:unit).to_s.should.include 'Pods/Target Support Files/CoconutLib/CoconutLib-Unit-Tests-frameworks.sh' @test_pod_target.embed_frameworks_script_path_for_test_type(:unit).to_s.should.include 'Pods/Target Support Files/CoconutLib/CoconutLib-Unit-Tests-frameworks.sh'
end end
it 'returns the correct resource path for test resource bundles' do
fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
fa.stubs(:resource_bundles).returns('TestResourceBundle' => [Pathname.new('Model.xcdatamodeld')])
fa.stubs(:resources).returns([])
fa.stubs(:spec).returns(stub(:test_specification? => true))
@test_pod_target.stubs(:file_accessors).returns([fa])
@test_pod_target.resource_paths.should == ['$PODS_CONFIGURATION_BUILD_DIR/TestResourceBundle.bundle']
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