#!/bin/bash # build_app.sh — Compila o app SwiftUI (GArt.app) a partir dos fontes em MacApp/Sources. # # Uso: # ./MacApp/build_app.sh # compila e monta o .app em MacApp/build/ # ./MacApp/build_app.sh --run # compila e abre o app set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" SDK="$(xcrun --sdk macosx --show-sdk-path)" TARGET="arm64-apple-macosx26.0" APP_NAME="GArt" BUILD_DIR="$ROOT/MacApp/build" APP_BUNDLE="$BUILD_DIR/$APP_NAME.app" CONTENTS="$APP_BUNDLE/Contents" MACOS="$CONTENTS/MacOS" RESOURCES="$CONTENTS/Resources" echo "==> Compilando SwiftUI ($APP_NAME)..." mkdir -p "$MACOS" "$RESOURCES" swiftc -parse-as-library -O \ -sdk "$SDK" \ -target "$TARGET" \ "$ROOT"/MacApp/Sources/*.swift \ -o "$MACOS/$APP_NAME" # Info.plist cat > "$CONTENTS/Info.plist" << PLIST CFBundleName$APP_NAME CFBundleDisplayNameG-ART CFBundleIdentifiercom.gart.transcription CFBundleVersion0.1 CFBundleShortVersionString0.1.0 CFBundleExecutable$APP_NAME CFBundlePackageTypeAPPL LSMinimumSystemVersion14.0 NSPrincipalClassNSApplication NSHighResolutionCapable UTExportedTypeDeclarations UTTypeIdentifiercom.genial.fcpxml UTTypeDescriptionFinal Cut Pro XML UTTypeConformsTopublic.xml UTTypeTagSpecification public.filename-extension fcpxml public.mime-type text/xml PLIST # Ícone (se existir) if [ -f "$ROOT/MacApp/Assets/AppIcon.icns" ]; then cp "$ROOT/MacApp/Assets/AppIcon.icns" "$RESOURCES/AppIcon.icns" # Referenciar no Info.plist /usr/libexec/PlistBuddy -c "Add :CFBundleIconFile string AppIcon" "$CONTENTS/Info.plist" 2>/dev/null || true fi chmod +x "$MACOS/$APP_NAME" echo "==> App criado: $APP_BUNDLE" if [[ "${1:-}" == "--run" ]]; then echo "==> Abrindo app..." open "$APP_BUNDLE" fi