-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.sh
More file actions
executable file
·80 lines (70 loc) · 2.7 KB
/
Copy pathbundle.sh
File metadata and controls
executable file
·80 lines (70 loc) · 2.7 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
#!/usr/bin/env bash
#
# Assemble a proper LSUIElement (.app) menu-bar bundle from the SwiftPM release
# build and ad-hoc sign it. This is the standard CLT-only, no-Xcode pattern:
# release build -> hand-assembled .app -> codesign -s -.
#
# Output: ./dist/Night Walker.app
# Bundle id stays com.flo.color-filter-scheduler (historical).
set -euo pipefail
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APP_NAME="Night Walker"
BUNDLE_ID="com.flo.color-filter-scheduler"
EXECUTABLE="color-filter-scheduler"
VERSION="1.0.0"
DIST="$REPO_DIR/dist"
APP="$DIST/$APP_NAME.app"
echo "==> Building (swift build -c release)…"
cd "$REPO_DIR"
swift build -c release
BUILT="$REPO_DIR/.build/release/$EXECUTABLE"
[[ -x "$BUILT" ]] || { echo "error: build did not produce $BUILT" >&2; exit 1; }
echo "==> Assembling $APP"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "$BUILT" "$APP/Contents/MacOS/$EXECUTABLE"
echo "==> Rendering app icon (.icns)"
ICON_TMP="$(mktemp -d)"
cleanup_icon_tmp() {
# Delete only the exact directory mktemp created for this run.
if [[ -n "${ICON_TMP:-}" && -d "$ICON_TMP" ]]; then
rm -rf -- "$ICON_TMP"
fi
}
trap cleanup_icon_tmp EXIT
ICONSET="$ICON_TMP/AppIcon.iconset"
swift "$REPO_DIR/tools/make-appicon.swift" "$ICONSET"
if iconutil -c icns "$ICONSET" -o "$APP/Contents/Resources/AppIcon.icns"; then
ICON_KEY=' <key>CFBundleIconFile</key> <string>AppIcon</string>'
else
echo "warning: iconutil failed; bundling without .icns" >&2
ICON_KEY=''
fi
cat > "$APP/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key> <string>$APP_NAME</string>
<key>CFBundleDisplayName</key> <string>$APP_NAME</string>
<key>CFBundleIdentifier</key> <string>$BUNDLE_ID</string>
<key>CFBundleExecutable</key> <string>$EXECUTABLE</string>
<key>CFBundleVersion</key> <string>$VERSION</string>
<key>CFBundleShortVersionString</key> <string>$VERSION</string>
<key>CFBundlePackageType</key> <string>APPL</string>
$ICON_KEY
<key>LSMinimumSystemVersion</key> <string>13.0</string>
<!-- Menu-bar-only agent: no Dock icon, no main window. -->
<key>LSUIElement</key> <true/>
<key>NSHighResolutionCapable</key> <true/>
</dict>
</plist>
EOF
# Marker so bundled-app UserDefaults/domain is unambiguous.
printf 'APPL????' > "$APP/Contents/PkgInfo"
echo "==> Ad-hoc signing"
codesign --force --sign - --identifier "$BUNDLE_ID" "$APP"
codesign --verify --verbose=1 "$APP"
echo
echo "Built: $APP"
echo "Run it directly with: open \"$APP\""