Files
LektorenPlan/Scripts/build-app.sh
T

80 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
CONFIG="${1:-debug}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
echo "Baue LektorenPlan ($CONFIG)…"
swift build -c "$CONFIG"
BIN_DIR="$(swift build -c "$CONFIG" --show-bin-path)"
APP="$ROOT/build/LektorenPlan.app"
CONTENTS="$APP/Contents"
MACOS="$CONTENTS/MacOS"
RESOURCES="$CONTENTS/Resources"
rm -rf "$APP"
mkdir -p "$MACOS" "$RESOURCES"
cp "$BIN_DIR/LektorenPlan" "$MACOS/LektorenPlan"
# App icon
if [ -f "$ROOT/Resources/AppIcon.icns" ]; then
cp "$ROOT/Resources/AppIcon.icns" "$RESOURCES/AppIcon.icns"
fi
# Copy SwiftPM resource bundles so Bundle.module keeps working inside the app.
for bundle in "$BIN_DIR"/*.bundle; do
[ -e "$bundle" ] || continue
cp -R "$bundle" "$RESOURCES/"
done
cat > "$CONTENTS/Info.plist" <<'PLIST'
<?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>CFBundleDevelopmentRegion</key>
<string>de</string>
<key>CFBundleExecutable</key>
<string>LektorenPlan</string>
<key>CFBundleIdentifier</key>
<string>de.badgodesberg.lektorenplan</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>LektorenPlan</string>
<key>CFBundleDisplayName</key>
<string>LektorenPlan</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.9</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>BuildDate</key>
<string>__BUILD_ISO_DATE__</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHumanReadableCopyright</key>
<string>LektorenPlan 0.9 · Build __BUILD_DISPLAY_DATE__ · Pfarreiengemeinschaft Bad Godesberg</string>
</dict>
</plist>
PLIST
BUILD_ISO_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
BUILD_DISPLAY_DATE="$(date +"%d.%m.%Y, %H:%M")"
/usr/bin/sed -i '' \
-e "s/__BUILD_ISO_DATE__/$BUILD_ISO_DATE/" \
-e "s/__BUILD_DISPLAY_DATE__/$BUILD_DISPLAY_DATE/" \
"$CONTENTS/Info.plist"
echo "Fertig: $APP"