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)

Fix
  • Loading branch information
mplorentz authored and dnkoutso committed May 22, 2020
1 parent 2b774aa commit 25ef334
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 31 deletions.
13 changes: 11 additions & 2 deletions 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, bcsymbol_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|
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 @@ -426,12 +426,7 @@ def embed_frameworks_input_paths(framework_paths, xcframeworks)
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]
[framework_output_path]
end.compact.uniq
# Static xcframeworks are not copied to the build dir
# so only include dynamic artifacts that will be copied to the build folder
Expand Down Expand Up @@ -576,6 +571,10 @@ def add_embed_frameworks_script_phase

input_paths_key = XCFileListConfigKey.new(target.embed_frameworks_script_input_files_path(config), target.embed_frameworks_script_input_files_relative_path)
input_paths_by_config[input_paths_key] = [script_path] + TargetIntegrator.embed_frameworks_input_paths(framework_paths, xcframeworks)
# input_paths << ARTIFACT_LIST_FILE if target.includes_xcframeworks?
# framework_paths.each do |path|
# input_paths.concat([path.source_path].compact)
# end

output_paths_key = XCFileListConfigKey.new(target.embed_frameworks_script_output_files_path(config), target.embed_frameworks_script_output_files_relative_path)
output_paths_by_config[output_paths_key] = TargetIntegrator.embed_frameworks_output_paths(framework_paths, xcframeworks)
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 @@ -141,7 +141,7 @@ def add_embed_frameworks_script_phase(native_target, spec)
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)
input_paths.concat << path.source_path
end

output_file_list_path = target.embed_frameworks_script_output_files_path_for_spec(spec)
Expand Down Expand Up @@ -209,8 +209,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 +228,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: 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 @@ -441,7 +441,7 @@ module Pod
it 'adds embed frameworks build phase input and output paths for vendored and non vendored frameworks' do
debug_vendored_framework = Xcode::FrameworkPaths.new('${PODS_ROOT}/DebugVendoredFramework/ios/DebugVendoredFramework.framework',
'${PODS_ROOT}/DebugVendoredFramework/ios/DebugVendoredFramework.framework.dSYM',
['${PODS_ROOT}/DebugVendoredFramework/ios/A6621399-62A0-3DC3-A6E3-B6B51BD287AD.bcsymbolmap'])
'${PODS_ROOT}/DebugVendoredFramework/ios/A6621399-62A0-3DC3-A6E3-B6B51BD287AD.bcsymbolmap')

debug_non_vendored_framework = Xcode::FrameworkPaths.new('${BUILT_PRODUCTS_DIR}/DebugCompiledFramework/DebugCompiledFramework.framework')

Expand All @@ -457,13 +457,11 @@ module Pod
phase = target.shell_script_build_phases.find { |bp| bp.name == @embed_framework_phase_name }
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 25ef334

Please sign in to comment.