4 ms·
Yes, you can do that. UniFFI allows you to generate Kotlin and Swift wrappers, which you can wrap in a RN wrapper. We did this at work for a cross-platform mobi
by yvgny 3y ago
Yes, you can do that. UniFFI allows you to generate Kotlin and Swift wrappers, which you can wrap in a RN wrapper. We did this at work for a cross-platform mobile app, it's a bit of a headache to create because that are some subtleties with async or these kind of things, and they are handled differently in the UniFFI wrappers and RN wrapper, but for relatively simple libs I find it pretty convenient.
- nicoburns 3y agoWhat would be really awesome would be a tool for generating JSI bindings to Rust code. Then you wouldn't need to go via Kotlin or Swift. I believe there are no technical barriers to such a tool. Someone just needs to implement it.
- pzo 3y agomaybe some ideas about interop can be taken from flutter module: https://github.com/fzyzcjy/flutter_rust_bridge https://github.com/fzyzcjy/flutter_rust_bridge
- zengid 3y agoMost of the details for doing this are over my head but wow what a nerd-snipe!
- nicoburns 3y agoIf you're looking for somewhere to start, then this repo which does some manual Rust <-> JSI integration might be a good one https://github.com/triniwiz/nativescript-mason https://github.com/triniwiz/nativescript-mason
- pzo 3y agoWouldn't this negate the effort of having cross platform Rust Module that now you have to manually create RN wrapper to autogenerated Kotlin and Swift wrappers? Also I think all previous RN bindings from JS to Swift, Java are async in nature end comes with performance penalty (serialization back and forth and async queue)? Would be great if React Native team extend TurboModules to support generating Rust interop instead of just C++ - there are many truely cross platform rust modules (including support for iOS/android) than c++ and cargo makes much better developer experience than cmake.