#!/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' CFBundleDevelopmentRegion de CFBundleExecutable LektorenPlan CFBundleIdentifier de.badgodesberg.lektorenplan CFBundleIconFile AppIcon CFBundleInfoDictionaryVersion 6.0 CFBundleName LektorenPlan CFBundleDisplayName LektorenPlan CFBundlePackageType APPL CFBundleShortVersionString 0.9 CFBundleVersion 1 BuildDate __BUILD_ISO_DATE__ LSMinimumSystemVersion 14.0 NSHighResolutionCapable NSPrincipalClass NSApplication NSHumanReadableCopyright LektorenPlan 0.9 · Build __BUILD_DISPLAY_DATE__ · Pfarreiengemeinschaft Bad Godesberg 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"