-
590 KB
+
~6 MB
App Size
@@ -417,7 +417,7 @@
Why ClearDisk?
| App Size |
- 590 KB |
+ ~6 MB |
~100 MB |
~25 MB |
~5 MB |
diff --git a/scripts/build_app.sh b/scripts/build_app.sh
index a3141bf..65d6d06 100755
--- a/scripts/build_app.sh
+++ b/scripts/build_app.sh
@@ -1,25 +1,77 @@
#!/bin/bash
-# Build ClearDisk.app bundle
-set -e
+# Build ClearDisk.app bundle (universal: arm64 + x86_64)
+set -euo pipefail
source "$(cd "$(dirname "$0")" && pwd)/_release_lib.sh"
VERSION="$(project_version)"
BUILD_NUMBER="$(git -C "$ROOT_DIR" rev-list --count HEAD)"
+# Architectures for the release binary. One DMG runs on Apple Silicon and Intel.
+# Override for a faster host-only build: ARCHES=arm64 ./scripts/build_app.sh
+ARCHES=(${ARCHES:-arm64 x86_64})
+
APP_BUNDLE="$ROOT_DIR/$APP_NAME.app"
+MACOS_DIR="$APP_BUNDLE/Contents/MacOS"
+BINARY_OUT="$MACOS_DIR/$APP_NAME"
+
+triple_for_arch() {
+ printf '%s-apple-macosx' "$1"
+}
+
+binary_path_for_arch() {
+ local arch="$1"
+ printf '%s/.build/%s/release/%s' "$ROOT_DIR" "$(triple_for_arch "$arch")" "$APP_NAME"
+}
+
+assert_universal() {
+ local info
+ info="$(lipo -info "$BINARY_OUT")"
+ echo "$info"
+ echo "$info" | grep -q 'arm64' || {
+ echo "error: fat binary missing arm64 slice: $info" >&2
+ exit 1
+ }
+ echo "$info" | grep -q 'x86_64' || {
+ echo "error: fat binary missing x86_64 slice: $info" >&2
+ exit 1
+ }
+}
-echo "Building $APP_NAME..."
+require_cmd swift
+require_cmd lipo
+require_cmd codesign
+require_cmd file
+
+echo "Building $APP_NAME (${ARCHES[*]})..."
cd "$ROOT_DIR"
-swift build -c release 2>&1
+
+BUILT_BINS=()
+for arch in "${ARCHES[@]}"; do
+ triple="$(triple_for_arch "$arch")"
+ echo " -> swift build -c release --triple $triple"
+ swift build -c release --triple "$triple" 2>&1
+ bin="$(binary_path_for_arch "$arch")"
+ if [ ! -f "$bin" ]; then
+ echo "error: expected binary missing after $arch build: $bin" >&2
+ exit 1
+ fi
+ BUILT_BINS+=("$bin")
+done
echo "Creating app bundle..."
rm -rf "$APP_BUNDLE"
-mkdir -p "$APP_BUNDLE/Contents/MacOS"
+mkdir -p "$MACOS_DIR"
mkdir -p "$APP_BUNDLE/Contents/Resources"
-# Copy binary
-cp ".build/release/$APP_NAME" "$APP_BUNDLE/Contents/MacOS/$APP_NAME"
+if [ "${#BUILT_BINS[@]}" -eq 1 ]; then
+ cp "${BUILT_BINS[0]}" "$BINARY_OUT"
+else
+ lipo -create "${BUILT_BINS[@]}" -output "$BINARY_OUT"
+ assert_universal
+fi
+
+file "$BINARY_OUT"
# Copy app icon
if [ -f "Resources/AppIcon.icns" ]; then
@@ -69,4 +121,4 @@ echo "Code signed (ad-hoc)."
echo "Done! App bundle created at: $APP_BUNDLE"
echo "To run: open $APP_BUNDLE"
-ls -la "$APP_BUNDLE/Contents/MacOS/$APP_NAME"
+ls -la "$BINARY_OUT"
diff --git a/scripts/do_dmg.sh b/scripts/do_dmg.sh
index be578f9..5816744 100755
--- a/scripts/do_dmg.sh
+++ b/scripts/do_dmg.sh
@@ -3,8 +3,8 @@
# Build the release .app and package it as dist/ClearDisk-v.dmg
#
# Usage:
-# ./scripts/do_dmg.sh # version comes from scripts/build_app.sh
-# ./scripts/do_dmg.sh --version 1.8.0 # only to double-check; must match build_app.sh
+# ./scripts/do_dmg.sh # version comes from CHANGELOG.md
+# ./scripts/do_dmg.sh --version 1.8.3 # only to double-check; must match CHANGELOG.md
#
# Writes the DMG plus a .sha256 sidecar that brew_update.sh picks up automatically.
@@ -27,16 +27,24 @@ DECLARED="$(project_version)"
if [ -z "$VERSION" ]; then
VERSION="$DECLARED"
elif [ "$VERSION" != "$DECLARED" ]; then
- die "--version $VERSION does not match VERSION=\"$DECLARED\" in scripts/build_app.sh.
+ die "--version $VERSION does not match \"$DECLARED\" in CHANGELOG.md.
Bump it there — that file is the single source of truth."
fi
info "Building $APP_NAME $VERSION (release)"
-"$SCRIPTS_DIR/build_app.sh" >/dev/null
+# Keep build_app stdout visible — it asserts universal slices and prints lipo/file output.
+"$SCRIPTS_DIR/build_app.sh"
APP="$ROOT_DIR/$APP_NAME.app"
[ -d "$APP" ] || die "$APP was not produced by build_app.sh"
+BIN="$APP/Contents/MacOS/$APP_NAME"
+[ -f "$BIN" ] || die "Missing executable: $BIN"
+LIPO_INFO="$(lipo -info "$BIN" 2>/dev/null || true)"
+echo "$LIPO_INFO" | grep -q 'arm64' || die "Release binary is not universal (missing arm64): $LIPO_INFO"
+echo "$LIPO_INFO" | grep -q 'x86_64' || die "Release binary is not universal (missing x86_64): $LIPO_INFO"
+ok "universal binary: $LIPO_INFO"
+
# The DMG filename is baked into the Homebrew cask URL, so a stale bundle would ship under the
# wrong name and every `brew install` would fetch the wrong build. Catch that here, not later.
BUILT="$(plutil -extract CFBundleShortVersionString raw "$APP/Contents/Info.plist")"