The bridge always wants to load a framework on iOS
Berrysoft opened this issue · comments
Describe the bug
I'm trying to upgrade a frbv1 project to frbv2. The upgrade is successful on Android, but not iOS. With frbv1, the native lib is built as staticlib with a project generated by cargo-xcode. However, after upgrading to frbv2, the dart side always wants to load native.framework/native
. I looked through the examples in this repo, but they all use cargokit. Is there a smooth upgrade path to still use the static lib without framework, or a way to change the xcode project to generate a dummy framework?
Steps to reproduce
The instructions here is interesting. Does dart_minimal
really run well on iOS?
Logs
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'native.framework/native': dlopen(native.framework/native, 0x0001): tried: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRootnative.framework/native' (errno=2), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/native.framework/native' (errno=2), '/usr/lib/swift/native.framework/native' (errno=2, not in dyld cache), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/native.framework/native' (errno=2), '/usr/lib/swift/native.framework/native' (errno=2, not in dyld cache), '/Users/berrysoft/Library/Developer<…>
Expected behavior
No response
Generated binding code
No response
OS
No response
Version of flutter_rust_bridge_codegen
No response
Flutter info
No response
Version of clang++
No response
Additional context
No response
Hi! Thanks for opening your first issue here! 😄
Hi, one way is to customize how the library is loaded: https://cjycode.com/flutter_rust_bridge/guides/how-to/load-library
Another way is to use flutter_rust_bridge_codegen create/integrate
to generate v2 scaffold in one command, and then move your code into that scaffold.
Does dart_minimal really run well on iOS?
Yes, this is guaranteed by running it on CI (all platforms are auto checked, as well as many other checks) ;)
@fzyzcjy Thank you for your advice! However after I choose to load the library from the process, the bridge complains cannot find store_dart_post_cobject
. I revert back the changes to use the dummy_method_to_enforce_bundling
method, but the generated header by codegen doesn't include the declaration of drop_dart_object
, get_dart_object
, new_dart_opaque
and store_dart_post_cobject
. Did I missed some steps?
P.S. I now generate the header with full_dep: true
Or, where should I change the link args to make the linker always link the static lib so that I don't need the dummy method to enforce bundling?
but the generated header by codegen doesn't include the declaration of drop_dart_object, get_dart_object, new_dart_opaque and store_dart_post_cobject.
Ok this seems to be a bug, because dummy_method_to_enforce_bundling is not used in the cargokit-based approach so I missed it - feel free to PR (looks like a good-first-issue
)! I guess it is as simple as, editing
func_names + EXTRA_EXTERN_FUNC_NAMES
.
Before fixing it, maybe firstly try to manually add that few functions, and see whether it works.
EDIT: Seems that it is already generated https://github.com/fzyzcjy/flutter_rust_bridge/blob/cfd88621f77de211a9c214508b2dfcca29efd4e7/frb_example/pure_dart/frb_generated.h#L16432
Btw, if your library does not customize the build process, then directly using flutter_rust_bridge_codegen create/integrate
may one of be the easiest way.
EDIT: Seems that it is already generated
The declaration is not generated:) I mean the signature void store_dart_post_cobject(DartPostCObjectFnType ptr);
is not generated.
And by the way it seems that the other 3 methods are no longer needed.
Oh looks reasonable!
P.S. Its declaration can be copied from
via a global search of the keywordThis thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.