Closed salvatoto closed 4 months ago
Thanks for the PR @salvatoto !
The binaries are building correctly. I will merge this and make a release with the mac/ios binaries.
If there are any issues with using the library following the release we can address it in a new PR.
Am trying to add it to my native iOS app through SPM dependency and seeking for advices. As far as I can see I could use the C libboltz framework and fed_generated.h interface to create SPM package. The missing part right now is translation of the rust interfaces/types/errors located in rust/src/api/ into swift api. Does that sounds correct flow? Any advice? should I use the dummyMethodToEnforceBundling in my app? Thanks for the awesome library!
Hey @cuhte3!
I am not familiar with iOS development and would not be able to comment on whether this flow would work.
AFAIK flutter_rust_bridge (frb) is best suited to translating files from rust to flutter. The flutter code then calls into the shared library binary files compiled in rust for ios. For Swift code, you maybe better served by a library like uniffi.
This is a good reference project: https://github.com/thunderbiscuit/uniffi-bindings-template
You could create a library using the same rust files as boltz-dart/rust and some uniffi macros to generate swift code.
Another good example of a rust project with Swift bindings: https://github.com/Blockstream/lwk/tree/master/lwk_bindings
Main issues resolved:
Copy ios binary to ios dir
, perhaps you want to handle differently. Just need to copy the built framework from rust/target to ios dirInstructions when adding to Flutter project:
Add this helper in Dart code:
And this obj-c helper in
NSBundleHelper.h
in iOS Runner project:Then point to pod framework for iOS. Android will be able to find the bare rust library
boltzclient
, however, since for iOS we wrap it in a cocoapods xcframework, we can find it this way:Add bundle helper and frb bindings to
Runner-Bridging-Header.h
in iOS Runner Project:34 Add
NSBundleHelper.m
to Xcode > Build Phases > Compile Sources if not there alreadydummyMethodToEnforceBundling
in ios/AppDelegate. Don't call it, just need to be in that file so those functions aren't stripped during linking