-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·44 lines (37 loc) · 1.2 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.2 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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
APP="ClipStash.app"
BIN="ClipStash"
# Generate the app icon from source if it isn't present yet.
if [ ! -f AppIcon.icns ]; then
echo "==> Generating app icon…"
swiftc -O -o make_icon make_icon.swift
rm -rf AppIcon.iconset
./make_icon AppIcon.iconset >/dev/null
iconutil -c icns AppIcon.iconset -o AppIcon.icns
fi
echo "==> Compiling ($(uname -m))…"
rm -rf "$APP"
swiftc -O -o "$BIN" main.swift
echo "==> Assembling app bundle…"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
mv "$BIN" "$APP/Contents/MacOS/$BIN"
cp Info.plist "$APP/Contents/Info.plist"
cp AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"
echo "==> Ad-hoc code signing (required to run on Apple Silicon)…"
codesign --force --sign - "$APP"
echo "==> Built: $(pwd)/$APP"
# Pass --install to also copy into /Applications and relaunch.
if [ "${1:-}" = "--install" ]; then
DEST="/Applications/$APP"
echo "==> Installing to ${DEST} ..."
osascript -e 'quit app "ClipStash"' 2>/dev/null || true
pkill -f "$BIN" 2>/dev/null || true
sleep 1
rm -rf "$DEST"
cp -R "$APP" "$DEST"
codesign --force --sign - "$DEST"
open "$DEST"
echo "==> Installed and launched."
fi