Properly merge manually compiled `xcassets` resources with the app target

parent 4739ff19
...@@ -55,6 +55,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -55,6 +55,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes ##### Bug Fixes
* Prevent `xcassets` compilation from stomping over the apps `xcassets`
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7003](https://github.com/CocoaPods/CocoaPods/issues/7003)
* Fix script phase output path for `.xcasset` resources * Fix script phase output path for `.xcasset` resources
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7511](https://github.com/CocoaPods/CocoaPods/issues/7511) [#7511](https://github.com/CocoaPods/CocoaPods/issues/7511)
......
...@@ -212,7 +212,11 @@ then ...@@ -212,7 +212,11 @@ then
fi fi
done <<<"$OTHER_XCASSETS" done <<<"$OTHER_XCASSETS"
printf "%s\\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then
printf "%s\\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
else
printf "%s\\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_BUILD_DIR}/assetcatalog_generated_info.plist"
fi
fi fi
EOS EOS
end end
......
...@@ -220,6 +220,9 @@ module Pod ...@@ -220,6 +220,9 @@ module Pod
# Returns an extension in the target that corresponds to the # Returns an extension in the target that corresponds to the
# resource's input extension. # resource's input extension.
# #
# @param [String] input_extension
# The input extension to map to.
#
# @return [String] The output extension. # @return [String] The output extension.
# #
def output_extension_for_resource(input_extension) def output_extension_for_resource(input_extension)
...@@ -234,6 +237,23 @@ module Pod ...@@ -234,6 +237,23 @@ module Pod
else input_extension else input_extension
end end
end end
# Returns the resource output paths for all given input paths.
#
# @param [Array<String>] resource_input_paths
# The input paths to map to.
#
# @return [Array<String>] The resource output paths.
#
def resource_output_paths(resource_input_paths)
resource_input_paths.map do |resource_input_path|
base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'
extname = File.extname(resource_input_path)
basename = extname == '.xcassets' ? 'Assets' : File.basename(resource_input_path)
output_extension = TargetIntegrator.output_extension_for_resource(extname)
File.join(base_path, File.basename(basename, extname) + output_extension)
end.uniq
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**
...@@ -309,14 +329,7 @@ module Pod ...@@ -309,14 +329,7 @@ module Pod
else else
resource_paths_flattened = resource_paths_by_config.values.flatten.uniq resource_paths_flattened = resource_paths_by_config.values.flatten.uniq
input_paths = [target.copy_resources_script_relative_path, *resource_paths_flattened] input_paths = [target.copy_resources_script_relative_path, *resource_paths_flattened]
# convert input paths to output paths according to extensions output_paths = TargetIntegrator.resource_output_paths(resource_paths_flattened)
output_paths = resource_paths_flattened.map do |input_path|
base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'
extname = File.extname(input_path)
basename = extname == '.xcassets' ? 'Assets' : File.basename(input_path)
output_extension = TargetIntegrator.output_extension_for_resource(extname)
File.join(base_path, File.basename(basename, extname) + output_extension)
end.uniq
TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths) TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)
TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths) TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths)
end end
......
...@@ -58,11 +58,7 @@ module Pod ...@@ -58,11 +58,7 @@ module Pod
unless resource_paths.empty? unless resource_paths.empty?
resource_paths_flattened = resource_paths.flatten.uniq resource_paths_flattened = resource_paths.flatten.uniq
input_paths = [script_path, *resource_paths_flattened] input_paths = [script_path, *resource_paths_flattened]
output_paths = resource_paths_flattened.map do |input_path| output_paths = UserProjectIntegrator::TargetIntegrator.resource_output_paths(resource_paths_flattened)
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.validate_input_output_path_limit(input_paths, output_paths) UserProjectIntegrator::TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)
UserProjectIntegrator::TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths) UserProjectIntegrator::TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths)
......
Subproject commit 47a72afc0f4cd1cb4c13a17e756055b79e6a85b4 Subproject commit 8037f4d7cf4b08d5af3f6e2867dbfa15edaf9dc2
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