#!/bin/bash set -euo pipefail # Load .env if present (for CERT_NAME etc.) ENV_FILE="$(dirname "$0")/.env" if [ -f "$ENV_FILE" ]; then set -a source "$ENV_FILE" set +a fi CERT_NAME="${CERT_NAME:-}" APP_DIR="$(dirname "$0")/build/MCT.app" SDK=$(xcrun --show-sdk-path) echo "Building MCT..." # Kill running instance if any pkill -x MCT 2>/dev/null || true sleep 0.3 # Create bundle structure mkdir -p "$APP_DIR/Contents/MacOS" "$APP_DIR/Contents/Resources" # Compile swiftc \ -emit-executable \ -o "$APP_DIR/Contents/MacOS/MCT" \ -sdk "$SDK" \ -target arm64-apple-macosx14.0 \ -swift-version 5 \ -O \ -Xlinker -framework -Xlinker ScreenCaptureKit \ MCT/Model/WindowInfo.swift \ MCT/Model/WindowGroup.swift \ MCT/Model/WindowSnapshot.swift \ MCT/Model/LayoutState.swift \ MCT/Model/GestureProgress.swift \ MCT/API/WindowEnumerator.swift \ MCT/API/ThumbnailCapture.swift \ MCT/API/AccessibilityBridge.swift \ MCT/API/HotKeyManager.swift \ MCT/API/GestureMonitor.swift \ MCT/Layout/LayoutGeometry.swift \ MCT/Layout/LayoutEngine.swift \ MCT/UI/SpringAnimator.swift \ MCT/UI/OverlayWindowController.swift \ MCT/UI/OverlayView.swift \ MCT/UI/WindowThumbnailView.swift \ MCT/UI/AppGroupHeaderView.swift \ MCT/Settings/Preferences.swift \ MCT/Settings/SettingsView.swift \ MCT/App/AppDelegate.swift \ MCT/App/MCTApp.swift # Info.plist cat > "$APP_DIR/Contents/Info.plist" << 'PLIST' CFBundleDevelopmentRegion en CFBundleExecutable MCT CFBundleIdentifier com.mct.app CFBundleInfoDictionaryVersion 6.0 CFBundleName Mission Control Turbo CFBundleDisplayName Mission Control Turbo CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleVersion 1 LSMinimumSystemVersion 14.0 LSUIElement NSHumanReadableCopyright Copyright 2026. All rights reserved. NSScreenCaptureUsageDescription MCT needs Screen Recording permission to capture window thumbnails for the overlay. NSAccessibilityUsageDescription MCT needs Accessibility permission to register a global hotkey and activate windows. PLIST echo -n "APPL????" > "$APP_DIR/Contents/PkgInfo" # Code-sign the app so macOS recognizes it for permission grants if [ -n "$CERT_NAME" ]; then codesign --force --sign "$CERT_NAME" "$APP_DIR" else codesign --force --sign - "$APP_DIR" fi echo "Built: $APP_DIR" open "$APP_DIR"