#!/usr/bin/env bash # Release build → dist/mwb.app, signed. # # Usage: MWB_SIGN_IDENTITY="mwb-mac dev" tools/bundle.sh # MWB_ADHOC=1 tools/bundle.sh # ad-hoc signature, for a throwaway build only # # A stable signing identity matters: macOS TCC ties the Accessibility and # Input Monitoring grants to the code signature, and an ad-hoc signature # changes with every build, so the user would be re-prompted each time # (README D5). Create a self-signed identity once with Keychain Access # (Certificate Assistant > Create a Certificate, type "Code Signing") and # pass its name via MWB_SIGN_IDENTITY. set -euo pipefail root=$(cd "$(dirname "$0")/.." && pwd) cd "$root" app="dist/mwb.app" identity="${MWB_SIGN_IDENTITY:-}" if [ -z "$identity" ]; then if [ "${MWB_ADHOC:-0}" = 1 ]; then identity="-" echo "bundle.sh: ad-hoc signing (MWB_ADHOC=1); TCC grants will not persist across builds" >&2 else echo "bundle.sh: set MWB_SIGN_IDENTITY to a code-signing identity, or MWB_ADHOC=1 for a throwaway build" >&2 exit 2 fi fi swift build -c release 2>&1 | grep -v '^\[' || true swift build -c release >/dev/null bin=$(swift build -c release --show-bin-path)/mwb rm -rf "$app" mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" cp "$bin" "$app/Contents/MacOS/mwb" cp Resources/Info.plist "$app/Contents/Info.plist" codesign --force --sign "$identity" --options runtime --timestamp=none "$app" codesign --verify --verbose=2 "$app" echo "built $app"