Skip to content

Commit

Permalink
Move *.bcsymbolmap installation from Embed Frameworks phase to Copy d…
Browse files Browse the repository at this point in the history
…SYMs phase (#9419)
  • Loading branch information
mplorentz authored and dnkoutso committed May 22, 2020
1 parent 7673c15 commit ce3581f
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 46 deletions.
11 changes: 10 additions & 1 deletion lib/cocoapods/generator/copy_dsyms_script.rb
Expand Up @@ -5,12 +5,17 @@ class CopydSYMsScript
#
attr_reader :dsym_paths

# @return [Array<Pathname>] bcsymbolmap_paths the bcsymbolmap paths to include in the script contents.
#
attr_reader :bcsymbolmap_paths

# Initialize a new instance
#
# @param [Array<Pathname>] dsym_paths @see dsym_paths
#
def initialize(dsym_paths)
def initialize(dsym_paths, bcsymbolmap_paths)
@dsym_paths = dsym_paths
@bcsymbolmap_paths = bcsymbolmap_paths
end

# Saves the copy dSYMs script to the given pathname.
Expand All @@ -35,10 +40,14 @@ def generate
#{Pod::Generator::ScriptPhaseConstants::STRIP_INVALID_ARCHITECTURES_METHOD}
#{Pod::Generator::ScriptPhaseConstants::RSYNC_PROTECT_TMP_FILES}
#{Pod::Generator::ScriptPhaseConstants::INSTALL_DSYM_METHOD}
#{Pod::Generator::ScriptPhaseConstants::INSTALL_BCSYMBOLMAP_METHOD}
SH
dsym_paths.each do |dsym_path|
script << %(install_dsym "#{dsym_path}"\n)
end
bcsymbolmap_paths.each do |bcsymbolmap_path|
script << %(install_bcsymbolmap "#{bcsymbolmap_path}"\n)
end
script
end
end
Expand Down
8 changes: 0 additions & 8 deletions lib/cocoapods/generator/embed_frameworks_script.rb
Expand Up @@ -130,14 +130,6 @@ def script
}
#{Pod::Generator::ScriptPhaseConstants::INSTALL_DSYM_METHOD}
#{Pod::Generator::ScriptPhaseConstants::STRIP_INVALID_ARCHITECTURES_METHOD}
# Copies the bcsymbolmap files of a vendored framework
install_bcsymbolmap() {
local bcsymbolmap_path="$1"
local destination="${BUILT_PRODUCTS_DIR}"
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${bcsymbolmap_path}\" \"${destination}\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"
}
# Signs a framework with the provided identity
code_sign_if_enabled() {
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
Expand Down
19 changes: 19 additions & 0 deletions lib/cocoapods/generator/script_phase_constants.rb
Expand Up @@ -82,6 +82,25 @@ module ScriptPhaseConstants
touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM"
fi
fi
}
SH

INSTALL_BCSYMBOLMAP_METHOD = <<-SH.strip_heredoc.freeze
# Copies bcsymbolmaps
install_bcsymbolmap() {
local source="$1"
warn_missing_arch=${2:-true}
if [ -r "$source" ]; then
# Copy the bcsymbolmap into the targets temp dir.
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" --filter \\"- Headers\\" --filter \\"- PrivateHeaders\\" --filter \\"- Modules\\" \\"${source}\\" \\"${DERIVED_FILES_DIR}\\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}"
local basename
basename="$(basename -s .bcsymbolmap "$source")"
# Move the stripped file into its final destination.
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" --filter \\"- Headers\\" --filter \\"- PrivateHeaders\\" --filter \\"- Modules\\" \\"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\\" \\"${DWARF_DSYM_FOLDER_PATH}\\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.bcsymbolmap" "${DWARF_DSYM_FOLDER_PATH}"
fi
}
SH
end
Expand Down
Expand Up @@ -391,20 +391,18 @@ def resource_output_paths(resource_input_paths)
end.uniq
end

# Returns the framework output paths for the given input paths
# Returns the framework input paths for the given framework paths
#
# @param [Hash<Array<Xcode::FrameworkPaths>>] framework_paths
# The target's framework paths to map to output paths.
# The target's framework paths to map to input paths.
#
# @param [Hash<Array<XCFramework>>] xcframeworks
# The target's xcframeworks to map to output paths.
# The target's xcframeworks to map to input paths.
#
# @return [Array<String>] The embed frameworks script input paths
#
def embed_frameworks_input_paths(framework_paths, xcframeworks)
input_paths = framework_paths.each_with_object([]) do |path, result|
result.concat([path.source_path, path.bcsymbolmap_paths].flatten.compact)
end
input_paths = framework_paths.map(&:source_path)
# Only include dynamic xcframeworks as the input since we will not be copying static xcframework slices
xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.each do |xcframework|
name = xcframework.name
Expand All @@ -413,26 +411,20 @@ def embed_frameworks_input_paths(framework_paths, xcframeworks)
input_paths
end

# Returns the framework output paths for the given input paths
# Returns the framework output paths for the given framework paths
#
# @param [Array<Xcode::FrameworkPaths>] framework_input_paths
# @param [Array<Xcode::FrameworkPaths>] framework_paths
# The framework input paths to map to output paths.
#
# @param [Array<XCFramework>] xcframeworks
# The installed xcframeworks.
#
# @return [Array<String>] The framework output paths
#
def embed_frameworks_output_paths(framework_input_paths, xcframeworks)
paths = framework_input_paths.flat_map do |framework_path|
framework_output_path = "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}"
bcsymbol_output_paths = unless framework_path.bcsymbolmap_paths.nil?
framework_path.bcsymbolmap_paths.map do |bcsymbolmap_path|
"${BUILT_PRODUCTS_DIR}/#{File.basename(bcsymbolmap_path)}"
end
end
[framework_output_path, *bcsymbol_output_paths]
end.compact.uniq
# @return [Array<String>] The embed framework script output paths
#
def embed_frameworks_output_paths(framework_paths, xcframeworks)
paths = framework_paths.map do |framework_path|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}"
end.uniq
# Static xcframeworks are not copied to the build dir
# so only include dynamic artifacts that will be copied to the build folder
xcframework_paths = xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.map do |xcframework|
Expand Down
Expand Up @@ -776,15 +776,16 @@ def create_app_target_embed_frameworks_script(app_spec)
end
end

# Creates a script that copies and strips vendored dSYMs.
# Creates a script that copies and strips vendored dSYMs and bcsymbolmaps.
#
# @return [void]
#
def create_copy_dsyms_script
dsym_paths = PodTargetInstaller.dsym_paths(target)
bcsymbolmap_paths = target.framework_paths.values.flatten.reject { |fmwk_path| fmwk_path.bcsymbolmap_paths.nil? }.map(&:bcsymbolmap_paths)
path = target.copy_dsyms_script_path
unless dsym_paths.empty?
generator = Generator::CopydSYMsScript.new(dsym_paths)
unless dsym_paths.empty? && bcsymbolmap_paths.empty?
generator = Generator::CopydSYMsScript.new(dsym_paths, bcsymbolmap_paths)
update_changed_file(generator, path)
add_file_to_support_group(path)
end
Expand Down
Expand Up @@ -139,10 +139,7 @@ def add_embed_frameworks_script_phase(native_target, spec)
input_file_list_path = target.embed_frameworks_script_input_files_path_for_spec(spec)
input_file_list_relative_path = "${PODS_ROOT}/#{input_file_list_path.relative_path_from(target.sandbox.root)}"
input_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(input_file_list_path, input_file_list_relative_path)
input_paths = input_paths_by_config[input_paths_key] = [script_path]
framework_paths.each do |path|
input_paths.concat([path.source_path, path.bcsymbolmap_paths].flatten.compact)
end
input_paths_by_config[input_paths_key] = [script_path] + UserProjectIntegrator::TargetIntegrator.embed_frameworks_input_paths(framework_paths, [])

output_file_list_path = target.embed_frameworks_script_output_files_path_for_spec(spec)
output_file_list_relative_path = "${PODS_ROOT}/#{output_file_list_path.relative_path_from(target.sandbox.root)}"
Expand Down Expand Up @@ -209,8 +206,9 @@ def add_copy_xcframeworks_script_phase(native_target)
def add_copy_dsyms_script_phase(native_target)
script_path = "${PODS_ROOT}/#{target.copy_dsyms_script_path.relative_path_from(target.sandbox.root)}"
dsym_paths = PodTargetInstaller.dsym_paths(target)
bcsymbolmap_paths = target.framework_paths.values.flatten.reject { |fmwk_path| fmwk_path.bcsymbolmap_paths.nil? }.map(&:bcsymbolmap_paths).flatten

if dsym_paths.empty?
if dsym_paths.empty? && bcsymbolmap_paths.empty?
script_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(UserProjectIntegrator::TargetIntegrator::COPY_DSYM_FILES_PHASE_NAME) }
native_target.build_phases.delete(script_phase) if script_phase.present?
return
Expand All @@ -227,15 +225,16 @@ def add_copy_dsyms_script_phase(native_target)
input_file_list_relative_path = "${PODS_ROOT}/#{input_file_list_path.relative_path_from(target.sandbox.root)}"
input_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(input_file_list_path, input_file_list_relative_path)
input_paths = input_paths_by_config[input_paths_key] = []
input_paths.concat dsym_paths
input_paths.concat([dsym_paths, *bcsymbolmap_paths].flatten.compact)

output_file_list_path = target.copy_dsyms_script_output_files_path
output_file_list_relative_path = "${PODS_ROOT}/#{output_file_list_path.relative_path_from(target.sandbox.root)}"
output_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(output_file_list_path, output_file_list_relative_path)
output_paths = output_paths_by_config[output_paths_key] = []

dsym_output_paths = dsym_paths.map { |dsym_path| "${DWARF_DSYM_FOLDER_PATH}/#{File.basename(dsym_path)}" }
output_paths.concat dsym_output_paths
bcsymbolmap_output_paths = bcsymbolmap_paths.map { |bcsymbolmap_path| "${DWARF_DSYM_FOLDER_PATH}/#{File.basename(bcsymbolmap_path)}" }
output_paths.concat([dsym_output_paths, *bcsymbolmap_output_paths].flatten.compact)
end

UserProjectIntegrator::TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)
Expand Down
2 changes: 1 addition & 1 deletion spec/cocoapods-integration-specs
Submodule cocoapods-integration-specs updated 32 files
+0 −8 install_custom_module_map/after/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh
+0 −8 install_custom_module_name/after/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh
+0 −8 install_framework_resources/after/Pods/Target Support Files/Pods-SampleApp/Pods-SampleApp-frameworks.sh
+0 −8 ...l_header_mappings_dir/after/Pods/Target Support Files/Pods-OtherSampleApp/Pods-OtherSampleApp-frameworks.sh
+0 −8 ...er_mappings_dir_macos/after/Pods/Target Support Files/Pods-OtherSampleApp/Pods-OtherSampleApp-frameworks.sh
+0 −8 install_multiple_test_specs/after/Pods/Target Support Files/HostedTestLib/HostedTestLib-App-frameworks.sh
+0 −8 ...ll_multiple_test_specs/after/Pods/Target Support Files/HostedTestLib/HostedTestLib-AppWithDep-frameworks.sh
+0 −8 ...ltiple_test_specs/after/Pods/Target Support Files/HostedTestLib/HostedTestLib-Unit-UnitTests3-frameworks.sh
+0 −8 ...ltiple_test_specs/after/Pods/Target Support Files/HostedTestLib/HostedTestLib-Unit-UnitTests4-frameworks.sh
+0 −8 ...s/after/Pods/Target Support Files/Pods-InstallMultipleTestSpecs/Pods-InstallMultipleTestSpecs-frameworks.sh
+0 −8 install_multiple_test_specs/after/Pods/Target Support Files/Pods-Other/Pods-Other-frameworks.sh
+0 −8 install_multiple_test_specs/after/Pods/Target Support Files/TestLib/TestLib-App-frameworks.sh
+0 −8 install_multiple_test_specs/after/Pods/Target Support Files/TestLib/TestLib-Unit-UnitTests1-frameworks.sh
+0 −8 install_multiple_test_specs/after/Pods/Target Support Files/TestLib/TestLib-Unit-UnitTests2-frameworks.sh
+0 −8 install_search_paths_inheritance/after/Pods/Target Support Files/Pods-App/Pods-App-frameworks.sh
+0 −8 install_search_paths_inheritance/after/Pods/Target Support Files/Pods-Test/Pods-Test-frameworks.sh
+0 −8 ...et Support Files/CustomModuleMapPod-framework-iOS/CustomModuleMapPod-framework-iOS-Unit-Tests-frameworks.sh
+0 −8 ...upport Files/CustomModuleMapPod-framework-macOS/CustomModuleMapPod-framework-macOS-Unit-Tests-frameworks.sh
+0 −8 ...ules/after/Pods/Target Support Files/MixedPod-framework-iOS/MixedPod-framework-iOS-Unit-Tests-frameworks.sh
+0 −8 .../after/Pods/Target Support Files/MixedPod-framework-macOS/MixedPod-framework-macOS-Unit-Tests-frameworks.sh
+0 −8 ...odules/after/Pods/Target Support Files/ObjCPod-framework-iOS/ObjCPod-framework-iOS-Unit-Tests-frameworks.sh
+0 −8 ...es/after/Pods/Target Support Files/ObjCPod-framework-macOS/ObjCPod-framework-macOS-Unit-Tests-frameworks.sh
+0 −8 ...get Support Files/Pods-Abstract Target-iOS Pods-Dynamic/Pods-Abstract Target-iOS Pods-Dynamic-frameworks.sh
+0 −8 ...Support Files/Pods-Abstract Target-macOS Pods-Dynamic/Pods-Abstract Target-macOS Pods-Dynamic-frameworks.sh
+0 −8 ...ules/after/Pods/Target Support Files/SwiftPod-framework-iOS/SwiftPod-framework-iOS-Unit-Tests-frameworks.sh
+0 −8 .../after/Pods/Target Support Files/SwiftPod-framework-macOS/SwiftPod-framework-macOS-Unit-Tests-frameworks.sh
+0 −8 install_subspecs/after/Pods/Target Support Files/Pods-OS X App/Pods-OS X App-frameworks.sh
+1 −0 install_vendored_dynamic_framework/after/Pods/Pods.xcodeproj
+0 −8 install_vendored_dynamic_framework/after/Pods/Target Support Files/Pods-SampleApp/Pods-SampleApp-frameworks.sh
+94 −0 install_vendored_dynamic_framework/after/Pods/Target Support Files/Realm/Realm-copy-dsyms.sh
+0 −8 install_vendored_xcframework/after/Pods/Target Support Files/BananaLib/BananaLib-Unit-Tests-frameworks.sh
+0 −8 ...ework/after/Pods/Target Support Files/Pods-XCFrameworkIntegration/Pods-XCFrameworkIntegration-frameworks.sh
2 changes: 0 additions & 2 deletions spec/unit/generator/embed_frameworks_script_spec.rb
Expand Up @@ -34,8 +34,6 @@ module Pod
result.should.include <<-SH.strip_heredoc
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "Pods/Loopback.framework"
install_bcsymbolmap "7724D6B4-C7DD-31F0-80C6-EE818ED30B07.bcsymbolmap"
install_bcsymbolmap "B724D6B4-C7DD-31F0-80C6-EE818ED30B0B.bcsymbolmap"
install_framework "Reveal.framework"
fi
SH
Expand Down
Expand Up @@ -455,15 +455,15 @@ module Pod
@target_integrator.integrate!
target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == @embed_framework_phase_name }
# dSYM and bcsymbolmaps are intentionally excluded as they are handled by a different script phase within
# the pod target.
phase.input_paths.sort.should == %w(
${BUILT_PRODUCTS_DIR}/DebugCompiledFramework/DebugCompiledFramework.framework
${PODS_ROOT}/DebugVendoredFramework/ios/A6621399-62A0-3DC3-A6E3-B6B51BD287AD.bcsymbolmap
${PODS_ROOT}/DebugVendoredFramework/ios/DebugVendoredFramework.framework
${PODS_ROOT}/ReleaseVendoredFramework/ios/ReleaseVendoredFramework.framework
${PODS_ROOT}/Target\ Support\ Files/Pods/Pods-frameworks.sh
)
phase.output_paths.sort.should == %w(
${BUILT_PRODUCTS_DIR}/A6621399-62A0-3DC3-A6E3-B6B51BD287AD.bcsymbolmap
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DebugCompiledFramework.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DebugVendoredFramework.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ReleaseVendoredFramework.framework
Expand Down
Expand Up @@ -237,7 +237,8 @@ class PodTargetIntegrator

it 'integrates native target with copy dSYM script phase' do
framework_paths = [Pod::Xcode::FrameworkPaths.new('${PODS_ROOT}/Vendored/Vendored.framework',
'${PODS_ROOT}/Vendored/Vendored.framework.dSYM')]
'${PODS_ROOT}/Vendored/Vendored.framework.dSYM',
'${PODS_ROOT}/Vendored/7724D6B4-C7DD-31F0-80C6-EE818ED30B07.bcsymbolmap')]
@watermelon_pod_target.stubs(:framework_paths).returns('WatermelonLib' => framework_paths)
installation_result = TargetInstallationResult.new(@watermelon_pod_target, @native_target, [], [])
PodTargetIntegrator.new(installation_result, :use_input_output_paths => true).integrate!
Expand All @@ -247,16 +248,19 @@ class PodTargetIntegrator
]
@native_target.build_phases[0].input_paths.should == [
'${PODS_ROOT}/Vendored/Vendored.framework.dSYM',
'${PODS_ROOT}/Vendored/7724D6B4-C7DD-31F0-80C6-EE818ED30B07.bcsymbolmap',
]
@native_target.build_phases[0].output_paths.should == [
'${DWARF_DSYM_FOLDER_PATH}/Vendored.framework.dSYM',
'${DWARF_DSYM_FOLDER_PATH}/7724D6B4-C7DD-31F0-80C6-EE818ED30B07.bcsymbolmap',
]
end

it 'integrates native target with copy dSYM script phase and xcfilelists' do
@project.stubs(:object_version).returns('50')
framework_paths = [Pod::Xcode::FrameworkPaths.new('${PODS_ROOT}/Vendored/Vendored.framework',
'${PODS_ROOT}/Vendored/Vendored.framework.dSYM')]
'${PODS_ROOT}/Vendored/Vendored.framework.dSYM',
'${PODS_ROOT}/Vendored/7724D6B4-C7DD-31F0-80C6-EE818ED30B07.bcsymbolmap')]
@watermelon_pod_target.stubs(:framework_paths).returns('WatermelonLib' => framework_paths)
installation_result = TargetInstallationResult.new(@watermelon_pod_target, @native_target, [], [])
PodTargetIntegrator.new(installation_result, :use_input_output_paths => true).integrate!
Expand Down

0 comments on commit ce3581f

Please sign in to comment.