SDK: add Flutter/Dart bindings via flutter_rust_bridge#162
Open
saltyskip wants to merge 9 commits into
Open
Conversation
Adds a new `flutter_ffi` Rust crate that exposes the same API surface as
the existing UniFFI SDK but annotated for flutter_rust_bridge v2. CI
generates Dart bindings with `flutter_rust_bridge_codegen`, builds native
iOS XCFramework + Android .so files, and ships a self-contained
`rift-flutter-sdk-{tag}.tar.gz` release artifact alongside the existing
iOS and Android tarballs.
Storage is owned by the Dart layer (no foreign trait needed): `RiftSdk.create()`
accepts pre-loaded state; methods that mutate state return a `RiftState`
snapshot for Dart to persist. The `SharedPrefsRiftStorage` default
implementation handles this transparently out of the box.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
flutter_rust_bridge_codegen v2.12 dropped file-glob rust_input in favor of Rust module paths. Move the API to src/api.rs and use --rust-input crate::api --rust-root flutter_ffi/ everywhere. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frb v2 detects the Dart package by walking up from dart-output to find pubspec.yaml. Generating into dist/ (no pubspec.yaml) fails. Fix: use --dart-root flutter_dart_wrappers/ so frb finds the pubspec, and drop --c-output / --no-web which aren't guaranteed flags in v2.12. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frb resolves --dart-output relative to cwd (not --dart-root), then walks up from that path looking for pubspec.yaml. Using "lib/src/rust/..." resolves inside client/mobile/ with no pubspec there. Using the full path flutter_dart_wrappers/lib/src/rust/frb_generated.dart lets frb find flutter_dart_wrappers/pubspec.yaml correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
flutter_rust_bridge_codegen v2 requires Dart/Flutter to be available to generate Dart bindings (it runs dart analysis internally). Add subosito/flutter-action@v2 to both the CI gen job and the release build-flutter job. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
flutter_rust_bridge_codegen v2 requires freezed (Dart codegen backend), freezed_annotation, build_runner, and flutter_rust_bridge as dependencies before it will generate bindings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frb v2 treats --dart-output as a directory name, not a file path — it was creating frb_generated.dart/ as a directory. Removing the flag lets frb place files in its expected default location inside the dart-root. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frb v2 treats --dart-output as a directory: it places frb_generated.dart inside it. Passing the full file path (ending in .dart) caused frb to create a directory named frb_generated.dart. Use the parent dir instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
macOS ships bash 3.2 which doesn't support associative arrays (declare -A, a bash 4+ feature). The build_flutter.sh xcodebuild runner is macOS-15 so this was the crash on line 65. Replace with a plain case statement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
client/mobile/flutter_ffi/— new Rust crate annotated for flutter_rust_bridge v2. Write Rust once; CI generates Swift + Kotlin + Dart.client/mobile/flutter_dart_wrappers/— committed hand-written Dart wrapper + Flutter plugin boilerplate (analogous toandroid-wrappers/). ExposesRiftSdk.create(publishableKey: ...)withSharedPrefsRiftStorageas the default storage backend.client/mobile/build_flutter.sh— runsflutter_rust_bridge_codegen generate, builds iOS XCFramework + Android.so, assemblesdist/flutter/as a distributable plugin tarball.mobile-sdk-ci.yml— addsflutter-dart-genjob that verifies Dart binding generation on every PR.mobile-sdk-release.yml— addsbuild-flutterjob; shipsrift-flutter-sdk-{tag}.tar.gzin the GitHub release alongside the existing iOS and Android artifacts.Storage: Dart layer owns persistence (no UniFFI foreign trait).
create()takes pre-loadedRiftState; state-mutating methods return a new snapshot.SharedPrefsRiftStoragehandles it transparently by default.Test plan
flutter-dart-genjob passes (Dart bindings generate cleanly)build-flutterrelease job producesflutter-sdk.tar.gzartifactflutter pub getresolvesRiftSdk.create(publishableKey: 'pk_live_...')initializes without error on device🤖 Generated with Claude Code