-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·60 lines (47 loc) · 1.64 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·60 lines (47 loc) · 1.64 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
#!/bin/bash
set -euo pipefail
APP_EXECUTABLE="ScreenshotSpace"
APP_DISPLAY_NAME="Screenshot Space"
BUILD_DIR=".build/debug"
DEV_BUNDLE="${BUILD_DIR}/${APP_DISPLAY_NAME}.app"
ICON_SOURCE="Assets/AppIcon/AppIcon.icns"
# Check for fswatch
if ! command -v fswatch &>/dev/null; then
echo "Error: fswatch is not installed."
echo "Install it with: brew install fswatch"
exit 1
fi
build_and_run() {
echo ""
echo "=== Building (debug)... ==="
# Kill the running instance if any
pkill -x "${APP_EXECUTABLE}" 2>/dev/null || true
sleep 0.3
# Build in debug mode (faster than release)
if ! swift build 2>&1; then
echo "=== Build failed ==="
return 1
fi
# Create minimal app bundle (no codesigning for dev)
rm -rf "${DEV_BUNDLE}"
mkdir -p "${DEV_BUNDLE}/Contents/MacOS"
mkdir -p "${DEV_BUNDLE}/Contents/Resources"
cp "${BUILD_DIR}/${APP_EXECUTABLE}" "${DEV_BUNDLE}/Contents/MacOS/${APP_EXECUTABLE}"
cp "Info.plist" "${DEV_BUNDLE}/Contents/"
if [ -f "${ICON_SOURCE}" ]; then
cp "${ICON_SOURCE}" "${DEV_BUNDLE}/Contents/Resources/AppIcon.icns"
fi
# Ad-hoc sign (required for Accessibility permissions in dev)
codesign --force --deep --sign - "${DEV_BUNDLE}"
echo "=== Launching... ==="
open "${DEV_BUNDLE}" &
echo "=== Ready. Watching for changes... ==="
}
# Initial build and run
build_and_run
# Watch Sources/ for changes and rebuild
fswatch -o -l 0.5 --exclude '.*\.build.*' --exclude '.*\.git.*' Sources/ Info.plist | while read -r _; do
# Debounce: drain any additional events that arrived
while read -r -t 0.3 _; do :; done
build_and_run
done