fix(mac): clean failed dSYM merges

This commit is contained in:
Vincent Koc
2026-06-21 13:30:20 +02:00
parent d1cbe29f3d
commit b7fef7fca6
2 changed files with 26 additions and 3 deletions

View File

@@ -162,6 +162,17 @@ cleanup_notary_zip() {
fi
}
cleanup_tmp_dsym() {
rm -rf "$TMP_DSYM"
}
copy_dsym_to_tmp() {
if ! cp -R "$1" "$TMP_DSYM"; then
cleanup_tmp_dsym
exit 1
fi
}
if [[ "$SKIP_NOTARIZE" == "1" ]]; then
NOTARIZE=0
fi
@@ -245,25 +256,30 @@ if [[ "$SKIP_DSYM" != "1" ]]; then
TMP_DSYM="$ROOT_DIR/dist/$PRODUCT.dSYM"
rm -rf "$TMP_DSYM"
if [[ "${#DSYM_PATHS[@]}" -gt 1 ]]; then
cp -R "${DSYM_PATHS[0]}" "$TMP_DSYM"
copy_dsym_to_tmp "${DSYM_PATHS[0]}"
DWARF_OUT="$TMP_DSYM/Contents/Resources/DWARF/$PRODUCT"
DWARF_INPUTS=()
for dsym in "${DSYM_PATHS[@]}"; do
DWARF_INPUT="$dsym/Contents/Resources/DWARF/$PRODUCT"
if [[ ! -f "$DWARF_INPUT" ]]; then
echo "Error: missing DWARF binaries for dSYM merge (set SKIP_DSYM=1 to skip symbols)" >&2
cleanup_tmp_dsym
exit 1
fi
DWARF_INPUTS+=("$DWARF_INPUT")
done
if [[ "${#DWARF_INPUTS[@]}" -gt 1 ]]; then
/usr/bin/lipo -create "${DWARF_INPUTS[@]}" -output "$DWARF_OUT"
if ! /usr/bin/lipo -create "${DWARF_INPUTS[@]}" -output "$DWARF_OUT"; then
cleanup_tmp_dsym
exit 1
fi
else
echo "Error: missing DWARF binaries for dSYM merge (set SKIP_DSYM=1 to skip symbols)" >&2
cleanup_tmp_dsym
exit 1
fi
else
cp -R "${DSYM_PATHS[0]}" "$TMP_DSYM"
copy_dsym_to_tmp "${DSYM_PATHS[0]}"
fi
echo "🧩 dSYM: $DSYM_ZIP"
rm -f "$DSYM_ZIP"

View File

@@ -263,6 +263,13 @@ describe("package-mac-dist plist validation", () => {
expect(dsymBlock).toContain("Error: missing DWARF binaries for dSYM merge");
expect(dsymBlock).toContain("Error: dSYM not found");
expect(dsymBlock).toContain("exit 1");
expect(script).toContain('if ! cp -R "$1" "$TMP_DSYM"; then');
expect(dsymBlock).toContain("cleanup_tmp_dsym");
expect(dsymBlock).toContain('copy_dsym_to_tmp "${DSYM_PATHS[0]}"');
expect(dsymBlock).not.toContain('cp -R "${DSYM_PATHS[0]}" "$TMP_DSYM"');
expect(dsymBlock).toContain(
'if ! /usr/bin/lipo -create "${DWARF_INPUTS[@]}" -output "$DWARF_OUT"; then',
);
expect(dsymBlock).toContain('if ! ditto -c -k --keepParent "$TMP_DSYM" "$DSYM_ZIP"; then');
expect(dsymBlock).toContain('rm -rf "$TMP_DSYM"');
expect(dsymBlock).not.toContain("WARN:");