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

Merge pull request #7209 from igor-makarov/resource_bundles_splat

Add copied resources' paths to "Copy Pods Resources" output file list 
parents 1392c8f0 9046e78e
...@@ -18,6 +18,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -18,6 +18,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes ##### Bug Fixes
* Add copied resources' paths to "Copy Pods Resources" output file list
[igor-makarov](https://github.com/igor-makarov)
[#6936](https://github.com/CocoaPods/CocoaPods/issues/6936)
* Do not link system frameworks of test specs to library targets * Do not link system frameworks of test specs to library targets
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7205](https://github.com/CocoaPods/CocoaPods/pull/7205) [#7205](https://github.com/CocoaPods/CocoaPods/pull/7205)
......
...@@ -190,6 +190,23 @@ module Pod ...@@ -190,6 +190,23 @@ module Pod
end end
end end
end end
# Returns an extension in the target that corresponds to the
# resource's input extension.
#
# @return [String] The output extension.
#
def output_extension_for_resource(input_extension)
case input_extension
when '.storyboard' then '.storyboardc'
when '.xib' then '.nib'
when '.framework' then '.framework'
when '.xcdatamodel' then '.mom'
when '.xcdatamodeld' then '.momd'
when '.xcmappingmodel' then '.cdm'
else input_extension
end
end
end end
# Integrates the user project targets. Only the targets that do **not** # Integrates the user project targets. Only the targets that do **not**
...@@ -263,8 +280,14 @@ module Pod ...@@ -263,8 +280,14 @@ module Pod
input_paths = [] input_paths = []
output_paths = [] output_paths = []
unless resource_paths_by_config.values.all?(&:empty?) unless resource_paths_by_config.values.all?(&:empty?)
input_paths = [target.copy_resources_script_relative_path, *resource_paths_by_config.values.flatten.uniq] resource_paths_flattened = resource_paths_by_config.values.flatten.uniq
output_paths = ['${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'] input_paths = [target.copy_resources_script_relative_path, *resource_paths_flattened]
# convert input paths to output paths according to extensions
output_paths = resource_paths_flattened.map do |input_path|
base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'
output_extension = TargetIntegrator.output_extension_for_resource(File.extname(input_path))
File.join(base_path, File.basename(input_path, File.extname(input_path)) + output_extension)
end
end end
TargetIntegrator.add_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths) TargetIntegrator.add_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths)
end end
......
...@@ -56,8 +56,13 @@ module Pod ...@@ -56,8 +56,13 @@ module Pod
input_paths = [] input_paths = []
output_paths = [] output_paths = []
unless resource_paths.empty? unless resource_paths.empty?
input_paths = [script_path, *resource_paths.flatten.uniq] resource_paths_flattened = resource_paths.flatten.uniq
output_paths = ['${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'] input_paths = [script_path, *resource_paths_flattened]
output_paths = resource_paths_flattened.map do |input_path|
base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'
output_extension = UserProjectIntegrator::TargetIntegrator.output_extension_for_resource(File.extname(input_path))
File.join(base_path, File.basename(input_path, File.extname(input_path)) + output_extension)
end
end end
UserProjectIntegrator::TargetIntegrator.add_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths) UserProjectIntegrator::TargetIntegrator.add_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths)
end end
......
...@@ -301,19 +301,41 @@ module Pod ...@@ -301,19 +301,41 @@ module Pod
it 'adds copy pods resources input and output paths' do it 'adds copy pods resources input and output paths' do
resource_paths_by_config = { resource_paths_by_config = {
'Debug' => ['${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugLib.bundle'], 'Debug' => [
'Release' => ['${PODS_CONFIGURATION_BUILD_DIR}/ReleaseLib/ReleaseLib.bundle'], '${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugDataModel.xcdatamodeld',
'${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugDataModel.xcdatamodel',
'${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugMappingModel.xcmappingmodel',
'${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugLib.bundle',
],
'Release' => [
'${PODS_CONFIGURATION_BUILD_DIR}/ReleaseLib/ReleaseLib.bundle',
'${PODS_CONFIGURATION_BUILD_DIR}/ReleaseLib/ReleaseLib.storyboard',
'${PODS_CONFIGURATION_BUILD_DIR}/ReleaseLib/ReleaseLibXIB.xib',
],
} }
@pod_bundle.stubs(:resource_paths_by_config => resource_paths_by_config) @pod_bundle.stubs(:resource_paths_by_config => resource_paths_by_config)
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == @copy_pods_resources_phase_name } phase = target.shell_script_build_phases.find { |bp| bp.name == @copy_pods_resources_phase_name }
phase.input_paths.sort.should == %w( phase.input_paths.sort.should == %w(
${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugDataModel.xcdatamodel
${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugDataModel.xcdatamodeld
${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugLib.bundle ${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugLib.bundle
${PODS_CONFIGURATION_BUILD_DIR}/DebugLib/DebugMappingModel.xcmappingmodel
${PODS_CONFIGURATION_BUILD_DIR}/ReleaseLib/ReleaseLib.bundle ${PODS_CONFIGURATION_BUILD_DIR}/ReleaseLib/ReleaseLib.bundle
${PODS_CONFIGURATION_BUILD_DIR}/ReleaseLib/ReleaseLib.storyboard
${PODS_CONFIGURATION_BUILD_DIR}/ReleaseLib/ReleaseLibXIB.xib
${SRCROOT}/../Pods/Target\ Support\ Files/Pods/Pods-resources.sh ${SRCROOT}/../Pods/Target\ Support\ Files/Pods/Pods-resources.sh
) )
phase.output_paths.sort.should == %w(${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}) phase.output_paths.sort.should == %w(
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/DebugDataModel.mom
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/DebugDataModel.momd
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/DebugLib.bundle
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/DebugMappingModel.cdm
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ReleaseLib.bundle
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ReleaseLib.storyboardc
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ReleaseLibXIB.nib
)
end end
it 'does not add embed frameworks build phase input output paths with no frameworks' do it 'does not add embed frameworks build phase input output paths with no frameworks' do
......
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
'${PODS_CONFIGURATION_BUILD_DIR}/TestResourceBundle.bundle', '${PODS_CONFIGURATION_BUILD_DIR}/TestResourceBundle.bundle',
] ]
@test_native_target.build_phases[1].output_paths.should == [ @test_native_target.build_phases[1].output_paths.should == [
'${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}', '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/TestResourceBundle.bundle',
] ]
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