#!/bin/bash # Builds CampusNAS.app — a menu bar agent, so it needs a real bundle: # UNUserNotificationCenter and SMAppService both refuse to work on a bare binary. set -euo pipefail cd "$(dirname "$0")" APP_NAME="CampusNAS" BUNDLE_ID="com.campusagro.campusnas-monitor" VERSION="1.0" APP="build/${APP_NAME}.app" # UNIVERSAL=1 builds for both architectures — needed when the .app will run on # a machine other than this one, which may be Intel. if [ "${UNIVERSAL:-0}" = "1" ]; then echo "==> swift build (arm64 + x86_64)" swift build -c release --arch arm64 --arch x86_64 BINARY=".build/apple/Products/Release/CampusNASMonitor" else echo "==> swift build" swift build -c release BINARY=".build/release/CampusNASMonitor" fi echo "==> assembling ${APP}" rm -rf "$APP" mkdir -p "${APP}/Contents/MacOS" "${APP}/Contents/Resources" cp "$BINARY" "${APP}/Contents/MacOS/${APP_NAME}" cat > "${APP}/Contents/Info.plist" < CFBundleName ${APP_NAME} CFBundleDisplayName ${APP_NAME} CFBundleIdentifier ${BUNDLE_ID} CFBundleExecutable ${APP_NAME} CFBundlePackageType APPL CFBundleShortVersionString ${VERSION} CFBundleVersion ${VERSION} LSMinimumSystemVersion 13.0 LSUIElement NSHumanReadableCopyright Internal tool PLIST plutil -lint "${APP}/Contents/Info.plist" >/dev/null echo "==> ad-hoc signing" codesign --force --sign - --timestamp=none "$APP" codesign --verify --verbose=1 "$APP" echo echo "Built: $(pwd)/${APP}" echo "Run: open '$(pwd)/${APP}'" echo "Install: cp -R '$(pwd)/${APP}' /Applications/"