Repository navigation
Expand file tree
/
Copy pathbuild_app.sh
More file actions
executable file
·109 lines (94 loc) · 4.02 KB
/
Copy pathbuild_app.sh
File metadata and controls
executable file
·109 lines (94 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
# build_app.sh — build MeowPassword.app bundle around the SwiftPM binaries.
#
# Produces ./MeowPassword.app with:
# Contents/MacOS/MeowPasswordApp (SwiftUI app, main entry)
# Contents/MacOS/meowpass (bundled CLI — the app shells out to it)
# Contents/Info.plist (URL scheme, Services, bundle metadata)
# Contents/Resources/Info.plist (SwiftPM resource bundle)
#
# Run:
# ./build_app.sh
# open MeowPassword.app
#
# Also wraps the app in a drag-to-Applications installer DMG via
# ./make_dmg.sh. Set SKIP_DMG=1 to skip that step (CI does — it builds
# its DMG separately, after Developer ID signing and notarization).
#
# The Services menu registers the first time the app runs.
# Grant it clipboard/automation access via System Settings → Privacy on first run.
set -euo pipefail
CONFIG="${CONFIG:-release}"
APP_NAME="MeowPassword"
APP_DIR="${APP_NAME}.app"
# Universal (Apple Silicon + Intel) by default. Set ARCHS=native for a faster,
# host-only build during development.
ARCHS="${ARCHS:-universal}"
if [[ "$ARCHS" == "universal" ]]; then
ARCH_FLAGS="--arch arm64 --arch x86_64"
# Universal builds land under .build/apple/Products/<Config>.
CONFIG_CAP="$(tr '[:lower:]' '[:upper:]' <<< "${CONFIG:0:1}")${CONFIG:1}"
BIN_DIR=".build/apple/Products/$CONFIG_CAP"
else
ARCH_FLAGS=""
BIN_DIR=".build/$CONFIG"
fi
echo "Building ($CONFIG, arch: $ARCHS)..."
swift build -c "$CONFIG" $ARCH_FLAGS --product meowpass
swift build -c "$CONFIG" $ARCH_FLAGS --product MeowPasswordApp
APP_BINARY="$BIN_DIR/MeowPasswordApp"
CLI_BINARY="$BIN_DIR/meowpass"
if [[ ! -x "$APP_BINARY" ]]; then
echo "ERROR: SwiftPM did not produce $APP_BINARY" >&2
exit 1
fi
if [[ ! -x "$CLI_BINARY" ]]; then
echo "ERROR: SwiftPM did not produce $CLI_BINARY" >&2
exit 1
fi
echo "Assembling $APP_DIR..."
rm -rf "$APP_DIR"
mkdir -p "$APP_DIR/Contents/MacOS"
mkdir -p "$APP_DIR/Contents/Resources"
cp "$APP_BINARY" "$APP_DIR/Contents/MacOS/$APP_NAME"
cp "$CLI_BINARY" "$APP_DIR/Contents/MacOS/meowpass"
cp Sources/MeowPasswordApp/Resources/Info.plist "$APP_DIR/Contents/Info.plist"
# Copy SwiftPM-generated resource bundles (app assets + the MeowGramKit
# bundle that carries the 100 keyed meowgram PNGs, loaded via Bundle.module).
for bundle in "$BIN_DIR"/*.bundle; do
if [[ -e "$bundle" ]]; then
cp -R "$bundle" "$APP_DIR/Contents/Resources/"
fi
done
# Also drop loose assets directly into Contents/Resources so Bundle.main
# lookups work without depending on SwiftPM's module bundle plumbing.
if [[ -d Sources/MeowPasswordApp/Assets ]]; then
cp Sources/MeowPasswordApp/Assets/*.png "$APP_DIR/Contents/Resources/" 2>/dev/null || true
cp Sources/MeowPasswordApp/Assets/*.jpg "$APP_DIR/Contents/Resources/" 2>/dev/null || true
cp Sources/MeowPasswordApp/Assets/AppIcon.icns "$APP_DIR/Contents/Resources/" 2>/dev/null || true
fi
# (Keyed MeowGram masters now ship inside the MeowGramKit resource bundle
# copied above, loaded at runtime via Bundle.module — no loose copy needed.)
# Point CFBundleExecutable at our renamed binary.
/usr/libexec/PlistBuddy -c "Set :CFBundleExecutable $APP_NAME" "$APP_DIR/Contents/Info.plist" 2>/dev/null || \
/usr/libexec/PlistBuddy -c "Add :CFBundleExecutable string $APP_NAME" "$APP_DIR/Contents/Info.plist"
# Ad-hoc sign so Launch Services / Gatekeeper accepts the local build.
# Entitlements are only applied when a real signing identity is set (from CI);
# ad-hoc signatures ignore them.
ENTITLEMENTS_FILE="Sources/MeowPasswordApp/Resources/MeowPassword.entitlements"
if [[ -n "${CODESIGN_IDENTITY:-}" && -f "$ENTITLEMENTS_FILE" ]]; then
codesign --force --deep --options runtime --timestamp \
--entitlements "$ENTITLEMENTS_FILE" \
--sign "$CODESIGN_IDENTITY" \
"$APP_DIR"
else
codesign --force --deep --sign - "$APP_DIR"
fi
echo
echo "Built $APP_DIR"
echo "Open with: open $APP_DIR"
echo "Register Services immediately: /System/Library/CoreServices/pbs -update"
if [[ "${SKIP_DMG:-0}" != "1" ]]; then
echo
./make_dmg.sh
fi