Open ethicnology opened 1 day ago
What are the steps to produce a package that is compatible with others ?
What about:
https://cjycode.com/flutter_rust_bridge/quickstart
Feel free to ping me if you have other questions after using this!
Yes, I've built my package using the plugin
template but is it enough ?
I've also follow the guide for precompiled_binaries
using cargokit
To solve this error:
Error (Xcode):
/lib/src/rust/frb_generated.dart:39:14: Error: The method 'initMockImpl' isn't defined for
the class 'RustLib'.
I have deleted the initMock
code from frb_generated.dart
but flutter_rust_bridge_codegen generate
keep re-generate it:
/// Initialize flutter_rust_bridge in mock mode.
/// No libraries for FFI are loaded.
static void initMock({
required LibBip85Api api,
}) {
instance.initMockImpl(
api: api,
);
}
Hmm, looks like a bug that some functions is not generated? Could you please provide a minimal reproducible sample (probably just a almost blank project)?
Using 2.6.0 execute flutter_rust_bridge_codegen create new_plugin --template plugin
and you can see initMock
with an undefined initMockImpl
, I guess it happened when I bump 2.5.0 to 2.6.0:
/// Initialize flutter_rust_bridge in mock mode.
/// No libraries for FFI are loaded.
static void initMock({
required RustLibApi api,
}) {
instance.initMockImpl(
api: api,
);
}
Great, I will check that later.
Btw, is your flutter_rust_bridge dart dependency in pubspec.yaml latest? IMHO in https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_dart/lib/src/main_components/entrypoint.dart#L68 the initMockImpl is there, so it should be able to find it.
When I execute the command flutter_rust_bridge_codegen create new_plugin --template plugin
the flutter_rust_bridge
dependency is 2.6.0
in the pubspec.yaml.
On my own project, I started with 2.5.0
, then upgraded to 2.6.0
and later, I had to downgrade to 2.0.0
because most other projects that rely on flutter_rust_bridge are stuck in this version and it creates incompatibility.
By the way, to reduce incompatibilities between packages made by people using rust_flutter_bridge
, it would be great if version is ^2.X.X
instead of strictly 2.X.X
but I don't know if there are restrictions about this.
This tool is great, it help us to grow the dart/flutter ecosystem
I had to downgrade to 2.0.0
Ok then I guess this is the issue: The 2.6.0 codegen generates code that is compatible with 2.6.0 runtime, instead of 2.0.0, which does not have that new function.
By the way, to reduce incompatibilities between packages made by people using rust_flutter_bridge , it would be great if version is ^2.X.X instead of strictly 2.X.X but I don't know if there are restrictions about this.
Yes that would be great. But currently it is the latter, because new codegen generated code often requires new code in the runtime. For example, the initMockImpl in the runtime as you have seen.
This tool is great, it help us to grow the dart/flutter ecosystem
Thanks and happy to see the ecosystem growing!
Ok then I guess this is the issue: The 2.6.0 codegen generates code that is compatible with 2.6.0 runtime, instead of 2.0.0, which does not have that new function.
On my project yes. But the error initMockImpl isn't defined for the type 'RustLib'
.
appears on a brand new --template plugin
that is fully 2.6.0
Thanks and happy to see the ecosystem growing!
Thank to your work!
But the error
Hmm then it's a bug. I guess it is relatively easy to fix, so feel free to PR! Alternatively I will work on it in the next batch.
Thank to your work!
You are welcome!
Is it only to add the following there ?
@protected
void initMockImpl({
required A api,
}) {
if (__state != null) {
throw StateError('Should not initialize flutter_rust_bridge twice');
}
__state = _FakeEntrypointState(api: api);
}
No, indeed I think it should already work, because the class extends BaseEntrypoint, and BaseEntrypoint has a initMockImpl method...
Well I cannot reproduce the bug:
Create it
(base) ➜ temp flutter_rust_bridge_codegen create --template plugin hi_app
[2024-11-22T01:05:37.800Z INFO frb_codegen/src/library/commands/flutter.rs:24] Execute `flutter create hi_app --template plugin_ffi --platforms android,ios,linux,macos,windows` (this may take a while)
[2024-11-22T01:05:46.736Z INFO frb_codegen/src/library/integration/creator.rs:45] Step: Inject flutter_rust_bridge related code
[2024-11-22T01:05:46.739Z INFO frb_codegen/src/library/integration/integrator.rs:37] Overlay template onto project
[2024-11-22T01:05:46.750Z INFO frb_codegen/src/library/integration/integrator.rs:65] Modify file permissions
[2024-11-22T01:05:46.750Z INFO frb_codegen/src/library/integration/integrator.rs:68] Add pub dependencies
[2024-11-22T01:05:46.750Z INFO frb_codegen/src/library/commands/flutter.rs:37] Execute flutter pub add integration_test --dev --sdk=flutter (this may take a while)
[2024-11-22T01:05:54.616Z INFO frb_codegen/src/library/commands/flutter.rs:37] Execute flutter pub add flutter_rust_bridge:2.6.0 (this may take a while)
[2024-11-22T01:06:01.550Z INFO frb_codegen/src/library/commands/flutter.rs:37] Execute flutter pub add integration_test --dev --sdk=flutter (this may take a while)
[2024-11-22T01:06:07.336Z INFO frb_codegen/src/library/integration/integrator.rs:76] Setup cargokit dependencies
[2024-11-22T01:06:07.336Z INFO frb_codegen/src/library/commands/flutter.rs:53] Execute `flutter pub get` inside "/Users/tom/temp/hi_app/cargokit/build_tool" (this may take a while)
[2024-11-22T01:06:14.667Z INFO frb_codegen/src/library/integration/integrator.rs:79] Apply Dart fixes
[2024-11-22T01:06:24.960Z INFO frb_codegen/src/library/integration/integrator.rs:82] Format Dart code
(base) ➜ temp cd hi_app
Analyze it:
➜ hi_app dart analyze
Analyzing hi_app... 6.2s
No issues found!
Run it: flutter run -d macos
I still guess it may be because your dart runtime version does not match codegen version...
Describe the bug
I maintain the rust-bip85 library and am working on porting it to the Flutter community, leveraging your excellent tool.
I’ve encountered an issue in a Flutter project that involves multiple packages using
flutter_rust_bridge
.I've noticed that some package such as
bdk_flutter
works with pre-compiled binaries. Other package likelwk
has a dedicated await LibLwk.init()Could you help me understand why in the case of a new project I face no issues, but run into problems when working with multiple other
flutter_rust_bridge
projects ?What are the steps to produce a package that is compatible with others ?
It would be really helpful to have a step-by-step guide for properly wrapping a Rust project for pub.dev
Steps to reproduce
git clone git@github.com:SatoshiPortal/bullbitcoin-mobile.git
flutter pub add bip85
Add in
lib/main.dart
flutter run
ios/android simulatorLogs
Expected behavior
No response
Generated binding code
No response
OS
MacOS
Version of
flutter_rust_bridge_codegen
2.6
Flutter info
Version of
clang++
No response
Additional context
No response