// swift-tools-version:5.10 import PackageDescription import Foundation // GrammaGem — native macOS menu-bar writing assistant. // // Layer-1 grammar is the real **Harper** core (Apache-2.0), embedded as a Rust // C-FFI static library (see `harper-ffi/`). Build the lib first with // `harper-ffi/build.sh`; `scripts/build.sh` does this automatically. // // Layer-2 AI (rewrite / tone / Ask) is the real on-device LLM via MLX // (mlx-swift-examples). MLX is **Apple-Silicon / Metal only**, so the app is // arm64-only (matches the product spec: Apple Silicon, macOS 14+). The Harper // static lib stays universal; the linker just uses its arm64 slice. // Absolute path to the prebuilt Harper static lib, independent of build cwd. let packageRoot = URL(fileURLWithPath: #filePath).deletingLastPathComponent().path let harperLibDir = packageRoot + "/harper-ffi/lib" let package = Package( name: "GrammaGem", platforms: [ .macOS(.v14) // Apple Silicon, macOS 14+ (per the product spec) ], products: [ .executable(name: "GrammaGem", targets: ["GrammaGem"]) ], dependencies: [ // On-device LLM runtime. Pinned to an exact tag (the LLM libraries still // ship from this repo at 2.25.9; the package name is "mlx-libraries"). .package(url: "https://github.com/ml-explore/mlx-swift-examples.git", exact: "2.25.9"), // Secure auto-updates (EdDSA-signed appcast served from grammagem.app). .package(url: "https://github.com/sparkle-project/Sparkle", from: "2.6.0"), ], targets: [ // C shim exposing libharper_ffi's C ABI (harper-ffi/include/harper.h) to Swift. .target(name: "CHarper", path: "Sources/CHarper"), .executableTarget( name: "GrammaGem", dependencies: [ "CHarper", .product(name: "MLXLLM", package: "mlx-swift-examples"), .product(name: "MLXLMCommon", package: "mlx-swift-examples"), .product(name: "Sparkle", package: "Sparkle"), ], path: "Sources/GrammaGem", linkerSettings: [ // Link the prebuilt Harper static library (arm64 slice). .unsafeFlags(["-L\(harperLibDir)", "-lharper_ffi"]) ] ), .testTarget( name: "GrammaGemTests", dependencies: ["GrammaGem"], path: "Tests/GrammaGemTests" ), ] )