This library has a unique build process due to its dependency on macOS 26.0+ beta and FoundationModels framework.
- macOS 26+ requirement: Uses Apple's FoundationModels framework (Apple Intelligence)
- Beta macOS only: No CI runners support macOS 26+ beta
- Complex toolchain: Requires Xcode 16+, Swift 6+, and Rust
- Apple Silicon only: ARM64 architecture requirement
# 1. Build native components (Swift + Rust)
bun run build:native
# 2. Build TypeScript
bun run build:ts
# Or build everything locally
bun run build:local# CI only builds TypeScript (native binaries are pre-built)
bun run build
# Validates pre-built binaries exist
bun run validate-binaries@meridius-labs/apple-on-device-ai/
├── build/ # ✅ COMMITTED to git
│ ├── apple_ai_napi.node # Pre-built Rust N-API addon
│ ├── libappleai.dylib # Pre-built Swift library
│ └── *.swiftmodule # Swift module files
├── dist/ # Built by CI/CD
│ ├── index.js # CommonJS bundle
│ ├── index.mjs # ESM bundle
│ └── *.d.ts # TypeScript definitions
└── native/target/release/ # ❌ NOT committed (too large)
Native components need rebuilding when:
- Swift code changes (
src/apple-ai.swift) - Rust code changes (
native/src/lib.rs) - Dependency updates (Cargo.toml, Swift frameworks)
- New macOS/Xcode version
# 1. Make changes to native code
# 2. Rebuild native components
bun run build:native
# 3. Test changes
bun run examples
# 4. Commit BOTH source and binaries
git add build/ src/ native/
git commit -m "Update native components"
# 5. Push - CI will handle TypeScript build
git push# 1. Make TypeScript changes
# 2. Test locally (using existing binaries)
bun run build:ts
bun run examples
# 3. Commit (no need to rebuild native)
git add src/
git commit -m "Update TypeScript code"
git push# 1. Make TypeScript-only changes
# 2. Submit PR - maintainer will rebuild native if needed
# 3. CI validates existing binaries work- ✅ Validates pre-built binaries exist
- ✅ Builds TypeScript with tsdown
- ✅ Runs tests
- ✅ Validates package contents
- ❌ Does NOT build native components
- ✅ Uses pre-built binaries
- ✅ Builds TypeScript
- ✅ Publishes to npm
- ❌ Does NOT build native components
The validate-binaries script ensures required native files exist:
// Checks for required files:
// - build/apple_ai_napi.node
// - build/libappleai.dylib
// - build/*.swiftmoduleWhen published, the package includes:
@meridius-labs/apple-on-device-ai/
├── package.json
├── README.md
├── dist/ # TypeScript build output
│ ├── index.js # CommonJS
│ ├── index.mjs # ESM
│ └── *.d.ts # Types
└── build/ # Pre-built native binaries
├── apple_ai_napi.node
├── libappleai.dylib
└── *.swiftmodule
- Cause:
build/directory missing or incomplete - Solution: Run
bun run build:nativeon macOS 26+
- Cause: Binaries built for wrong arch (x86_64 vs ARM64)
- Solution: Rebuild on Apple Silicon Mac
- Cause: Running on macOS < 26.0
- Solution: Upgrade to macOS 26+ beta or use pre-built package
- Cause: Native binaries not committed to git
- Solution: Commit
build/directory after local build
For distribution, binaries should be code-signed:
codesign --sign "Developer ID" build/apple_ai_napi.node
codesign --sign "Developer ID" build/libappleai.dylib- Pre-built binaries are committed to git for transparency
- All builds use consistent toolchain versions
- Reproducible builds planned for future versions