60 lines
1.6 KiB
Bash
Executable File
60 lines
1.6 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"
|
|
|
|
SDK=$(xcrun --show-sdk-path)
|
|
|
|
RUST_LIB="$ROOT/core/target/release"
|
|
echo "Building Rust core (release)..."
|
|
cd "$ROOT/core" && cargo build --release
|
|
cd "$ROOT"
|
|
RUST_FLAGS="-import-objc-header $ROOT/core/include/swiftly.h -L $RUST_LIB -lswiftly_core"
|
|
|
|
# --- App icon from SVG ---
|
|
SVG="$ROOT/static/vectors/icon.svg"
|
|
if [ -f "$SVG" ]; then
|
|
echo "Generating app icon..."
|
|
ICONSET="$BUILD/AppIcon.iconset"
|
|
mkdir -p "$ICONSET"
|
|
for SIZE in 16 32 64 128 256 512; do
|
|
rsvg-convert -w $SIZE -h $SIZE "$SVG" -o "$ICONSET/icon_${SIZE}x${SIZE}.png"
|
|
done
|
|
for SIZE in 16 32 128 256; do
|
|
DOUBLE=$((SIZE * 2))
|
|
rsvg-convert -w $DOUBLE -h $DOUBLE "$SVG" -o "$ICONSET/icon_${SIZE}x${SIZE}@2x.png"
|
|
done
|
|
rsvg-convert -w 1024 -h 1024 "$SVG" -o "$ICONSET/icon_512x512@2x.png"
|
|
iconutil -c icns "$ICONSET" -o "$BUILD/AppIcon.icns"
|
|
rm -rf "$ICONSET"
|
|
fi
|
|
|
|
# --- Bundle structure ---
|
|
mkdir -p "$MACOS" "$RESOURCES"
|
|
cp "$ROOT/Info.plist" "$CONTENTS/Info.plist"
|
|
if [ -f "$BUILD/AppIcon.icns" ]; then
|
|
cp "$BUILD/AppIcon.icns" "$RESOURCES/AppIcon.icns"
|
|
fi
|
|
|
|
# --- Compile Swift ---
|
|
echo "Compiling Swift (release)..."
|
|
swiftc \
|
|
-target arm64-apple-macosx14.0 \
|
|
-sdk "$SDK" \
|
|
$RUST_FLAGS \
|
|
-framework Cocoa \
|
|
-framework SwiftUI \
|
|
-O \
|
|
-o "$MACOS/Swiftly" \
|
|
"$ROOT"/src/*.swift
|
|
|
|
# --- Code sign ---
|
|
codesign --force --deep --sign - "$APP"
|
|
|
|
echo "Built: $APP"
|