Acord/debug.sh

52 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
BUILD="$ROOT/build"
APP="$BUILD/bin/Swiftly.app"
CONTENTS="$APP/Contents"
MACOS="$CONTENTS/MacOS"
RESOURCES="$CONTENTS/Resources"
LOGFILE="$HOME/swiftly/debug.log"
SDK=$(xcrun --show-sdk-path)
# --- Rust core (re-enable when backend is ready) ---
# RUST_LIB="$ROOT/core/target/debug"
# if [ -d "$ROOT/core" ]; then
# echo "Building Rust core (debug)..."
# cd "$ROOT/core" && cargo build
# cd "$ROOT"
# RUST_FLAGS="-import-objc-header $ROOT/core/include/swiftly.h -L $RUST_LIB -lswiftly_core"
# fi
RUST_FLAGS=""
# --- Bundle structure ---
mkdir -p "$MACOS" "$RESOURCES"
cp "$ROOT/Info.plist" "$CONTENTS/Info.plist"
# --- Compile Swift (debug) ---
echo "Compiling Swift (debug)..."
swiftc \
-target arm64-apple-macosx14.0 \
-sdk "$SDK" \
$RUST_FLAGS \
-framework Cocoa \
-framework SwiftUI \
-Onone -g \
-o "$MACOS/Swiftly" \
"$ROOT"/src/*.swift
# --- Code sign ---
codesign --force --deep --sign - "$APP"
# --- Kill existing, launch, tail log ---
pkill -f "Swiftly.app" 2>/dev/null || true
sleep 0.5
mkdir -p "$(dirname "$LOGFILE")"
open "$APP"
echo "Swiftly launched."
echo "Tail log: tail -f $LOGFILE"