Fold Apple SPM support into llamadart#198
Conversation
|
Chat app preview removed for |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #198 +/- ##
==========================================
+ Coverage 80.57% 80.59% +0.01%
==========================================
Files 85 85
Lines 11392 11407 +15
==========================================
+ Hits 9179 9193 +14
- Misses 2213 2214 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR folds Apple Swift Package Manager (SPM) support and the macOS LiteRT-LM native-assets fix into llamadart, aligning Apple and native-assets runtime sources and updating the pinned native runtime revisions.
Changes:
- Add an Apple SPM integration under
darwin/llamadartand route Flutter iOS/macOS builds to use SPM (with iOS 16.4 / macOS 14.0 floors), while keeping standalone Dart macOS on the native-assets fallback. - Update native runtime pins (
llamadart-native@b9536,litert-lm-native@v0.13.1), refresh LiteRT-LM runtime loading expectations (embedded StreamProxy), and adjust hook defaults so non-Android targets default tollama_cpponly. - Update docs, examples, CI smoke coverage, and hook/runtime-selection parsing (including OS-level overrides and exact-target precedence).
Reviewed changes
Copilot reviewed 51 out of 55 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/platforms/support-matrix.md | Updates pinned versions, runtime defaults, and documents the Apple SPM path and new floors. |
| website/docs/platforms/native-build-hooks.md | Documents new default runtime-family behavior and Apple SPM behavior for Flutter iOS/macOS. |
| website/docs/maintainers/runtime-ownership.md | Clarifies ownership boundaries for Apple SPM artifacts across repos. |
| website/docs/maintainers/release-workflow.md | Adds release checklist for keeping hook pins and SPM pins aligned. |
| website/docs/maintainers/native-and-web-sync.md | Defines the invariant: native-assets and SPM must resolve the same native releases; adds sync checklist. |
| website/docs/guides/backend-selection.md | Updates backend/runtime selection docs to match new defaults and per-OS/per-target config. |
| website/docs/getting-started/installation.md | Bumps the example native tag pin to b9536. |
| website/docs/examples/overview.md | Notes chat app opts into both runtime families; others use defaults. |
| website/docs/examples/chat-app.md | Documents chat app runtime-family selection and platform limitations. |
| tool/testing/test_matrix.dart | Updates test-matrix descriptions to reflect new LiteRT-LM smoke behavior. |
| tool/macos_litert_lm_prepare_app.sh | Updates macOS prepare logic to skip when SPM runtime is detected; stages dylibs into LiteRtLmRuntime/. |
| tool/macos_fair_litert_vs_llamadart.sh | Removes StreamProxy framework expectation (StreamProxy now embedded). |
| tool/litert_lm_library_smoke.dart | Adds a library/symbol smoke test for LiteRT-LM runtime loading in CI. |
| test/unit/tooling/macos_litert_lm_prepare_app_script_test.dart | Updates tests for new macOS runtime staging layout (libraries instead of frameworks). |
| test/unit/hook/native_bundle_config_test.dart | Adds OS-level runtime/backend override tests and updates default-runtime expectations. |
| test/unit/hook/build_hook_litert_lm_integration_test.dart | Updates LiteRT-LM hook integration expectations for SPM/process lookup and unavailable iOS x86_64 simulator runtime. |
| test/unit/hook/build_hook_linux_integration_test.dart | Updates Linux hook tests for new default runtime selection behavior. |
| test/unit/hook/build_hook_integration_test.dart | Updates Windows hook tests for new defaults and adds “all runtimes” coverage. |
| test/unit/hook/build_hook_android_integration_test.dart | Updates Android hook test expectations after StreamProxy removal. |
| test/unit/backends/litert_lm/litert_lm_runtime_test.dart | Updates runtime lookup candidates and required-libraries lists after StreamProxy embedding and SPM lookup changes. |
| README.md | Updates docs for runtime defaults, pins, and Apple SPM behavior. |
| pubspec.yaml | Adds Flutter SDK constraint and declares iOS/macOS plugin metadata for shared Darwin source. |
| lib/src/hook/native_bundle_config.dart | Implements per-OS platform keys + exact-target precedence for runtime/backend selection; changes defaults (Android vs others). |
| lib/src/backends/llama_cpp/llama_cpp_service.dart | Adjusts Apple backend-module loading behavior and adds iOS Frameworks search path for fallback lookups. |
| lib/src/backends/llama_cpp/bindings.dart | Regenerates/updates FFI bindings to match b9536 headers. |
| lib/src/backends/litert_lm/litert_lm_runtime.dart | Updates LiteRT-LM version, Apple SPM/process lookup handling, and embedded StreamProxy loading. |
| hook/build.dart | Updates pins and LiteRT-LM bundle spec structure; adds Apple SPM early-return path; changes runtime defaults and LiteRT-LM cache validation strategy. |
| example/README.md | Notes GGUF + LiteRT-LM routing in chat app and updated runtime download wording. |
| example/chat_app/test/litert_lm_benchmark_app_test.dart | Adds tests for benchmark backend selection and documents-relative model resolution. |
| example/chat_app/README.md | Documents opting into both runtime families and clarifies platform support for LiteRT-LM. |
| example/chat_app/pubspec.yaml | Opts the chat app into both runtime families with per-target exclusions where bundles aren’t published. |
| example/chat_app/macos/Runner.xcworkspace/contents.xcworkspacedata | Removes Pods reference from workspace. |
| example/chat_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | Adds a pre-build “prepare” action consistent with SwiftPM flow. |
| example/chat_app/macos/Runner.xcodeproj/project.pbxproj | Removes CocoaPods wiring; adds SwiftPM package reference; updates macOS deployment target to 14.0. |
| example/chat_app/macos/Podfile | Removes CocoaPods configuration for macOS. |
| example/chat_app/macos/Podfile.lock | Removes CocoaPods lockfile for macOS. |
| example/chat_app/macos/Flutter/GeneratedPluginRegistrant.swift | Adds llamadart plugin registration import/call. |
| example/chat_app/macos/Flutter/Flutter-Release.xcconfig | Removes Pods xcconfig include. |
| example/chat_app/macos/Flutter/Flutter-Debug.xcconfig | Removes Pods xcconfig include. |
| example/chat_app/lib/litert_lm_benchmark_app.dart | Improves backend selection defaults and resolves model paths via Documents on iOS (and via path_provider). |
| example/chat_app/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved | Adds SwiftPM resolution for iOS workspace dependencies. |
| example/chat_app/ios/Runner.xcworkspace/contents.xcworkspacedata | Removes Pods reference from workspace. |
| example/chat_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | Adds a pre-build “prepare” action consistent with SwiftPM flow. |
| example/chat_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved | Adds SwiftPM resolution for iOS project workspace dependencies. |
| example/chat_app/ios/Runner.xcodeproj/project.pbxproj | Removes CocoaPods wiring; adds SwiftPM package reference. |
| example/chat_app/ios/Podfile | Removes CocoaPods configuration for iOS. |
| example/chat_app/ios/Podfile.lock | Removes CocoaPods lockfile for iOS. |
| example/chat_app/ios/Flutter/Release.xcconfig | Removes Pods xcconfig include. |
| example/chat_app/ios/Flutter/Debug.xcconfig | Removes Pods xcconfig include. |
| example/chat_app/integration_test/smoke_test.dart | Makes GGUF smoke configurable and streams downloads to disk to avoid buffering multi-GB models. |
| darwin/llamadart/Sources/llamadart/LlamadartPlugin.swift | Adds a minimal Flutter plugin class to ensure SPM-linked symbols are present for process lookup. |
| darwin/llamadart/Package.swift | Adds SwiftPM manifest with binary targets pinned to llamadart-native/litert-lm-native release assets and checksums (with local Artifacts fallback). |
| CHANGELOG.md | Adds an Unreleased entry (currently only mentions runtime-default changes). |
| .github/workflows/sync_native_bindings.yml | Updates workflow name and checklist; includes darwin/llamadart/Package.swift in PR paths. |
| .github/workflows/litert_lm_smoke.yml | Adds native library smoke step and makes engine smoke conditional on model download; updates version resolution and cache usage. |
Files not reviewed (2)
- example/chat_app/ios/Runner.xcworkspace/contents.xcworkspacedata: Language not supported
- example/chat_app/macos/Runner.xcworkspace/contents.xcworkspacedata: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
main; Fix macOS LiteRT-LM runtime packaging #196 is closed as folded into this branch.leehack/llamadart-native@b9536andleehack/litert-lm-native@v0.13.1, so Apple SPM and native-assets paths consume the same native repos.llamadartpackage as the Apple SPM integration point instead of adding a separate package.llamadart_apple_spmuser define from the hook path and example app configuration.darwin/llamadart/Artifacts/*.xcframeworkfallback for branch-local SPM testing while keeping release URLs as the published path.b9536, wire the native SPM macOS LiteRT-LM layout, and keep pure Dart/native-assets behavior for desktop Dart consumers.version-0.7.0docs unchanged; current docs and maintainer docs describe the native version-management flow.Native Release Status
leehack/llamadart-native@b9536is published withllamadart-native-apple-xcframework-b9536.zip.leehack/litert-lm-native@v0.13.1is published with the Apple XCFramework zips used byPackage.swift.Package.swiftnow uses checksums from the uploaded GitHub release assets, not local test zips.Package.swiftchecksums for all Apple binary targets.Post-Release Remote SPM Validation
darwin/llamadart/Artifacts/aside and removed SwiftPM build state soPackage.swiftcould only expose remote GitHub release binary targets.swift package dump-package --package-path darwin/llamadartleehack/llamadart-nativeandleehack/litert-lm-native.13.1, with final uploaded checksums.flutter clean && rm -rf build/macos/SourcePackages && flutter pub get && flutter build macos --debugfromexample/chat_appflutter test integration_test/smoke_test.dart -d macos --dart-define=LLAMADART_GGUF_MODEL_URL=http://127.0.0.1:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=metalflutter test integration_test/smoke_test.dart -d macos --dart-define=LLAMADART_GGUF_MODEL_URL=http://127.0.0.1:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=cpuflutter test integration_test/smoke_test.dart -d 2E5F57B6-0C84-4B7D-8FC6-3AE46498246D --dart-define=LLAMADART_GGUF_MODEL_URL=http://127.0.0.1:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=metalflutter test integration_test/smoke_test.dart -d 2E5F57B6-0C84-4B7D-8FC6-3AE46498246D --dart-define=LLAMADART_GGUF_MODEL_URL=http://127.0.0.1:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=cpuflutter test --run-skipped -t local-only integration_test/litert_lm_chat_service_e2e_test.dart -d macos --dart-define=LITERT_LM_MODEL_URL=http://127.0.0.1:8787/gemma-4-E2B-it.litertlm --dart-define=LITERT_LM_E2E_BACKEND=cpuflutter test --run-skipped -t local-only integration_test/litert_lm_chat_service_e2e_test.dart -d macos --dart-define=LITERT_LM_MODEL_URL=http://127.0.0.1:8787/gemma-4-E2B-it.litertlm --dart-define=LITERT_LM_E2E_BACKEND=gpuflutter test --run-skipped -t local-only integration_test/litert_lm_chat_service_e2e_test.dart -d 2E5F57B6-0C84-4B7D-8FC6-3AE46498246D --dart-define=LITERT_LM_MODEL_URL=http://127.0.0.1:8787/gemma-4-E2B-it.litertlm --dart-define=LITERT_LM_E2E_BACKEND=cpuflutter drive --publish-port ... -d 00008103-001A59063EC0801E --dart-define=LLAMADART_GGUF_MODEL_URL=http://192.168.1.107:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=metalbuilt and installed, then blocked waiting for Dart VM service discovery over wireless.flutter drive ... -d 00008103-001A59063EC0801E --dart-define=LLAMADART_GGUF_MODEL_URL=http://192.168.1.107:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=cpualso built and installed, then hit the same wireless VM-service discovery/local-network permission blocker.Current Validation
git diff --checkdart test -p vm -j 1 test/unit/hook/build_hook_litert_lm_integration_test.dart test/unit/hook/native_bundle_config_test.dartllamadart_native_pathoverride; the hook resolvesleehack/llamadart-native@b9536and LiteRT-LM0.13.1.swift package dump-packagefromdarwin/llamadartwith localArtifacts/temporarily hidden.leehack/llamadart-native@b9536andleehack/litert-lm-native@v0.13.1with the uploaded checksums.gh release view b9536 --repo leehack/llamadart-native --json tagName,assets,urlgh release view v0.13.1 --repo leehack/litert-lm-native --json tagName,assets,urlEarlier Branch Validation
dart test test/unit/backends/litert_lm/litert_lm_runtime_test.dart test/unit/tooling/macos_litert_lm_prepare_app_script_test.dartflutter build macos --debugfromexample/chat_appswift package dump-packagefromdarwin/llamadartflutter clean && flutter pub get && flutter test integration_test/smoke_test.dart -d 2E5F57B6-0C84-4B7D-8FC6-3AE46498246Dflutter clean && flutter pub get && flutter test integration_test/smoke_test.dart -d macosb9536bundle:dart test test/integration/backends/llama_cpp/native_symbol_integration_test.dartdart test test/integration/inference_smoke_test.dartb9536was published:dart test -p vm -j 1 test/unit/hook --exclude-tags local-onlydart run tool/litert_lm_chat_features_smoke.dart .dart_tool/litert_lm_models/gemma-4-E2B-it.litertlm cpuflutter test --run-skipped -t local-only integration_test/litert_lm_chat_service_e2e_test.dart -d macos --dart-define=LITERT_LM_MODEL_URL=http://127.0.0.1:8787/gemma-4-E2B-it.litertlm --dart-define=LITERT_LM_E2E_BACKEND=cpuflutter test --run-skipped -t local-only integration_test/litert_lm_chat_service_e2e_test.dart -d 2E5F57B6-0C84-4B7D-8FC6-3AE46498246D --dart-define=LITERT_LM_MODEL_URL=http://127.0.0.1:8787/gemma-4-E2B-it.litertlm --dart-define=LITERT_LM_E2E_BACKEND=cpuflutter drive --publish-port --driver=test_driver/integration_test.dart --target=integration_test/litert_lm_chat_service_e2e_test.dart -d 00008103-001A59063EC0801E --dart-define=LITERT_LM_MODEL_URL=http://192.168.1.107:8787/gemma-4-E2B-it.litertlm --dart-define=LITERT_LM_E2E_BACKEND=cpudart run tool/litert_lm_chat_features_smoke.dart .dart_tool/litert_lm_models/gemma-4-E2B-it.litertlm gpuflutter test --run-skipped -t local-only integration_test/litert_lm_chat_service_e2e_test.dart -d macos --dart-define=LITERT_LM_MODEL_URL=http://127.0.0.1:8787/gemma-4-E2B-it.litertlm --dart-define=LITERT_LM_E2E_BACKEND=gpuAvailable LiteRT-LM backends: cpu.dart run tool/gguf_chat_features_smoke.dart models/gemma-4-E2B-it-Q4_K_S.gguf cpuflutter test integration_test/smoke_test.dart -d macos --dart-define=LLAMADART_GGUF_MODEL_URL=http://127.0.0.1:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=cpuflutter test integration_test/smoke_test.dart -d 2E5F57B6-0C84-4B7D-8FC6-3AE46498246D --dart-define=LLAMADART_GGUF_MODEL_URL=http://127.0.0.1:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=cpuflutter drive --publish-port --driver=test_driver/integration_test.dart --target=integration_test/smoke_test.dart -d 00008103-001A59063EC0801E --dart-define=LLAMADART_GGUF_MODEL_URL=http://192.168.1.107:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=cpudart run tool/gguf_chat_features_smoke.dart models/gemma-4-E2B-it-Q4_K_S.gguf metalflutter test integration_test/smoke_test.dart -d macos --dart-define=LLAMADART_GGUF_MODEL_URL=http://127.0.0.1:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=metalflutter test integration_test/smoke_test.dart -d 2E5F57B6-0C84-4B7D-8FC6-3AE46498246D --dart-define=LLAMADART_GGUF_MODEL_URL=http://127.0.0.1:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=metalflutter drive --publish-port --driver=test_driver/integration_test.dart --target=integration_test/smoke_test.dart -d 00008103-001A59063EC0801E --dart-define=LLAMADART_GGUF_MODEL_URL=http://192.168.1.107:8788/gemma-4-E2B-it-Q4_K_S.gguf --dart-define=LLAMADART_GGUF_BACKEND=metalvtool -show-build:llama.framework: minOS 16.4LiteRtLm.frameworkandCLiteRTLM.framework: minOS 15.0llamadart.framework: minOS 16.4LiteRtLm.frameworkandlibLiteRt.dylib: universal x86_64/arm64, minOS 14.0llama.framework: universal x86_64/arm64, minOS 13.3dart format hook/build.dart lib/src/hook/native_bundle_config.dart test/unit/hook/build_hook_litert_lm_integration_test.dartdart format lib/src/backends/litert_lm/litert_lm_runtime.dartdart format hook/build.dart lib/src/backends/litert_lm/litert_lm_runtime.dart lib/src/backends/llama_cpp/bindings.dart lib/src/backends/llama_cpp/llama_cpp_service.dart example/chat_app/integration_test/smoke_test.dartgit diff --checkRemaining Caveat
swift buildfromdarwin/llamadartis not a useful final gate because the package target importsFlutterMacOS; SwiftPM can parse the manifest and expose the binary targets, while Flutter/Xcode provides the Flutter framework in the real build.