grammargem/Package.swift
BigMarc e8b7dff65d Add Sparkle auto-update (appcast on grammagem.app)
Installed apps now show an 'Update available' button (menu bar) and can
one-click install signed updates. Adds the Sparkle dependency, an
UpdaterManager wired into AppState, the menu-bar banner + 'Check for
Updates', and Info.plist SUFeedURL (https://grammagem.app/appcast.xml),
SUPublicEDKey, and scheduled background checks.

Build / release:
- build.sh embeds + rpaths Sparkle.framework; sign-app.sh signs it
  inside-out (XPC services, Updater.app, Autoupdate, framework, then app)
  for a valid, notarizable signature.
- release.sh stamps the version, builds, signs, notarizes, staples, zips,
  and emits the EdDSA-signed appcast.xml to upload to grammagem.app.
- A hidden --update-selftest checks a feed headlessly (CI/build pipeline).

Verified: a v0.1.0 build detects a v0.2.0 update against a local signed
appcast (UPDATE_FOUND: 0.2.0); the signed app passes codesign --strict.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 08:22:35 +02:00

59 lines
2.4 KiB
Swift

// 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"
),
]
)