-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Improve dSYM handling for XCFrameworks #9540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,27 +129,29 @@ def script | |
# Copies and strips a vendored dSYM | ||
install_dsym() { | ||
local source="$1" | ||
warn_missing_arch=${2:-true} | ||
if [ -r "$source" ]; then | ||
# Copy the dSYM into a the targets temp dir. | ||
# Copy the dSYM 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 .framework.dSYM "$source")" | ||
binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" | ||
basename="$(basename -s .dSYM "$source")" | ||
binary_name="$(ls "$source/Contents/Resources/DWARF")" | ||
binary="${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}" | ||
|
||
# Strip invalid architectures so "fat" simulator / device frameworks work on device | ||
if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then | ||
strip_invalid_archs "$binary" | ||
strip_invalid_archs "$binary" "$warn_missing_arch" | ||
fi 8000 td> | ||
|
||
if [[ $STRIP_BINARY_RETVAL == 1 ]]; then | ||
# 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}.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}.dSYM" "${DWARF_DSYM_FOLDER_PATH}" | ||
else | ||
# The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. | ||
touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" | ||
touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM" | ||
fi | ||
fi | ||
} | ||
|
@@ -180,13 +182,16 @@ def script | |
# Strip invalid architectures | ||
strip_invalid_archs() { | ||
binary="$1" | ||
warn_missing_arch=${2:-true} | ||
# Get architectures for current target binary | ||
binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" | ||
# Intersect them with the architectures we are building for | ||
intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\\n' | sort | uniq -d)" | ||
# If there are no archs supported by this binary then warn the user | ||
if [[ -z "$intersected_archs" ]]; then | ||
echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." | ||
if [[ "$warn_missing_arch" == "true" ]]; then | ||
echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for xcframeworks, it's possible for a dSYM to be excluded completely due to archs not matching. this isn't an error, since there are multiple dSYMs instead of 1 |
||
fi | ||
STRIP_BINARY_RETVAL=0 | ||
return | ||
fi | ||
|
@@ -212,7 +217,8 @@ def script | |
install_framework "$artifact" | ||
;; | ||
*.dSYM) | ||
install_dsym "$artifact" | ||
# Suppress arch warnings since XCFrameworks will include many dSYM files | ||
install_dsym "$artifact" "false" | ||
;; | ||
*.bcsymbolmap) | ||
install_bcsymbolmap "$artifact" | ||
|
@@ -259,6 +265,18 @@ def script | |
SH | ||
script | ||
end | ||
|
||
# @param [Xcode::FrameworkPaths] framework_path | ||
# the framework path containing the dSYM | ||
# | ||
# @return [String, Nil] the name of the dSYM binary, if found | ||
# | ||
def dsym_binary_name(framework_path) | ||
return nil if framework_path.dsym_path.nil? | ||
if (path = Pathname.glob(framework_path.dsym_path.join('Contents/Resources/DWARF', '**/*')).first) | ||
File.basename(path) | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,8 @@ def script | |
|
||
install_xcframework() { | ||
local basepath="$1" | ||
local embed="$2" | ||
local dsym_folder="$2" | ||
local embed="$3" | ||
shift | ||
local paths=("$@") | ||
|
||
|
@@ -165,6 +166,17 @@ def script | |
fi | ||
|
||
install_framework "$basepath/$target_path" "$embed" | ||
< 8000 /td> | ||
if [[ -z "$dsym_folder" || ! -d "$dsym_folder" ]]; then | ||
return | ||
fi | ||
|
||
dsyms=($(ls "$dsym_folder")) | ||
|
||
local target_dsym="" | ||
for i in ${!dsyms[@]}; do | ||
install_artifact "$dsym_folder/${dsyms[$i]}" "$CONFIGURATION_BUILD_DIR" "true" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the prepare step, we now copy all dsyms and filter out the ones we need inside the |
||
done | ||
} | ||
|
||
SH | ||
|
@@ -186,12 +198,6 @@ def script | |
args = install_xcframework_args(xcframework.path, static_slices, true) | ||
contents_by_config[config] << %( install_xcframework #{args}\n) | ||
end | ||
|
||
dsyms = PrepareArtifactsScript.dsym_paths(xcframework.path) | ||
dsyms.each do |path| | ||
source = shell_escape("${PODS_ROOT}/#{path.relative_path_from(sandbox_root)}") | ||
contents_by_config[config] << %( install_artifact #{source} "${TARGET_BUILD_DIR}" "true"\n) | ||
end | ||
end | ||
end | ||
|
||
|
@@ -215,6 +221,12 @@ def shell_escape(value) | |
|
||
def install_xcframework_args(root, slices, static) | ||
args = [shell_escape("${PODS_ROOT}/#{root.relative_path_from(sandbox_root)}")] | ||
dsym_folder_arg = if (dsym_folder = PrepareArtifactsScript.dsym_folder(root)) | ||
shell_escape("${PODS_ROOT}/#{dsym_folder.relative_path_from(sandbox_root)}") | ||
else | ||
'""' | ||
end | ||
args << dsym_folder_arg | ||
embed = static ? 'false' : 'true' | ||
args << shell_escape(embed) | ||
slices.each do |slice| | ||
|
@@ -229,14 +241,11 @@ class << self | |
# | ||
# @return [Array<Pathname>] all found .dSYM paths | ||
# | ||
def dsym_paths(xcframework_path) | ||
def dsym_folder(xcframework_path) | ||
basename = File.basename(xcframework_path, '.xcframework') | ||
dsym_basename = basename + '.dSYMs' | ||
path = xcframework_path.dirname + dsym_basename | ||
return [] unless File.directory?(path) | ||
|
||
pattern = path + '*.dSYM' | ||
Dir.glob(pattern).map { |s| Pathname.new(s) } | ||
Pathname.new(path) if File.directory?(path) | ||
end | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the expected format for vendored frameworks, but since xcframeworks will have many dSYM files they must be named differently