Skip to content

Commit cfad261

Browse files
committed
Regenerate DMG from patched .app in fix-macos-local-build
The fix script rewrites the binary's libiconv reference from a Nix store path to /usr/lib/libiconv.2.dylib and re-signs the .app, but the DMG that `tauri build` already produced still embedded the un-patched .app, so mounting and running from the DMG crashed at launch with a code-signature mismatch on libiconv. After patching the .app, rebuild the DMG from it with hdiutil so locally-produced DMGs run on the same machine and on machines that do not have the Nix store.
1 parent 088e19b commit cfad261

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

scripts/fix-macos-local-build.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,23 @@ codesign --force --deep --sign - "$APP_PATH"
2121
xattr -cr "$APP_PATH"
2222

2323
echo "Patched and re-signed $APP_PATH"
24+
25+
# The DMG that `tauri build` produced still embeds the un-patched .app.
26+
# Regenerate it from the patched .app so mounting and running from the
27+
# DMG no longer crashes with a libiconv code-signature mismatch.
28+
DMG_DIR="$(dirname "$(dirname "$APP_PATH")")/dmg"
29+
if [[ -d "$DMG_DIR" ]]; then
30+
EXISTING_DMG="$(find "$DMG_DIR" -maxdepth 1 -name '*.dmg' -print -quit || true)"
31+
if [[ -n "${EXISTING_DMG:-}" ]]; then
32+
DMG_NAME="$(basename "$EXISTING_DMG")"
33+
APP_NAME="$(basename "$APP_PATH" .app)"
34+
rm -f "$EXISTING_DMG"
35+
hdiutil create \
36+
-volname "$APP_NAME" \
37+
-srcfolder "$APP_PATH" \
38+
-ov \
39+
-format UDZO \
40+
"$DMG_DIR/$DMG_NAME" >/dev/null
41+
echo "Rebuilt $DMG_DIR/$DMG_NAME from patched .app"
42+
fi
43+
fi

0 commit comments

Comments
 (0)