From b7fef7fca65b3f1d104a5e41c94fefaeefc10a88 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 13:30:20 +0200 Subject: [PATCH] fix(mac): clean failed dSYM merges --- scripts/package-mac-dist.sh | 22 +++++++++++++++++++--- test/scripts/package-mac-dist.test.ts | 7 +++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/scripts/package-mac-dist.sh b/scripts/package-mac-dist.sh index 948cdbf4197f..d290719a72f9 100755 --- a/scripts/package-mac-dist.sh +++ b/scripts/package-mac-dist.sh @@ -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" diff --git a/test/scripts/package-mac-dist.test.ts b/test/scripts/package-mac-dist.test.ts index 6f4bda60b752..746d5cba2ddb 100644 --- a/test/scripts/package-mac-dist.test.ts +++ b/test/scripts/package-mac-dist.test.ts @@ -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:");