| 1 | #!/bin/bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | src=$(cd "$(dirname "$0")" && pwd) |
| 5 | app=${1:?Specify a new output .app path} |
| 6 | [[ $app == *.app && ! -e $app ]] || { echo 'Choose a new .app path.' >&2; exit 2; } |
| 7 | mkdir -p "$app/Contents/MacOS" |
| 8 | cat > "$app/Contents/Info.plist" <<'PLIST' |
| 9 | <?xml version="1.0" encoding="UTF-8"?> |
| 10 | <plist version="1.0"><dict> |
| 11 | <key>CFBundleIdentifier</key><string>dev.cage.GuestClaudeWindow</string> |
| 12 | <key>CFBundleName</key><string>Cage Guest Window</string> |
| 13 | <key>CFBundleExecutable</key><string>CageGuestWindow</string> |
| 14 | <key>CFBundlePackageType</key><string>APPL</string> |
| 15 | <key>CFBundleShortVersionString</key><string>1.0</string> |
| 16 | <key>CFBundleVersion</key><string>1</string> |
| 17 | <key>LSUIElement</key><true/> |
| 18 | <key>CFBundleDocumentTypes</key><array><dict> |
| 19 | <key>CFBundleTypeName</key><string>Cage project file</string> |
| 20 | <key>CFBundleTypeRole</key><string>Viewer</string> |
| 21 | <key>LSHandlerRank</key><string>None</string> |
| 22 | <key>LSItemContentTypes</key><array><string>public.data</string></array> |
| 23 | </dict></array> |
| 24 | </dict></plist> |
| 25 | PLIST |
| 26 | objects=$(mktemp -d) |
| 27 | trap 'rm -rf "$objects"' EXIT |
| 28 | xcrun clang -target arm64-apple-macos14.0 -Wall -Wextra -Werror -O2 -c "$src/macos-file-writers.c" -o "$objects/file-writers.o" |
| 29 | xcrun swiftc -parse-as-library -D GUEST_WINDOW_APP -O -target arm64-apple-macos14.0 "$src/../../desktop/MacKeyboard.swift" "$src/claude-window-macos.swift" "$src/macos-diagnostics.swift" "$src/macos-claude-window-app.swift" "$src/macos-window-input.swift" "$src/macos-maintenance.swift" "$src/macos-setup-password.swift" "$src/macos-project-panel.swift" "$src/macos-claude-canvas.swift" "$src/macos-window-stream.swift" "$src/macos-audio.swift" "$src/macos-gui-session.swift" "$src/macos-phone-desktop.swift" "$src/macos-desktop-files.swift" "$src/macos-desktop-downloads.swift" "$src/macos-native-open.swift" "$objects/file-writers.o" -lbsm -o "$app/Contents/MacOS/CageGuestWindow" |
| 30 | codesign --force --sign "${CAGE_GUEST_SIGN_IDENTITY:-${CAGE_SIGNING_IDENTITY:--}}" --identifier dev.cage.GuestClaudeWindow "$app" |
| 31 | codesign --verify --strict "$app" |