talknagish / react-native-turbo-starter

React 0.68+ Turbo Module starter using codegen with typescript for Objective-C and Java/Kotlin with C++ shared library. 🚀🚀🚀
MIT License
380 stars 27 forks source link

Directly call C++ from JS #21

Open TimoGlastra opened 2 years ago

TimoGlastra commented 2 years ago

Would it be possible to extend this example with codegen that directly invokes c++ methods from JS? Not sure if that's already possible.

We've created a JSI library in c++ with a minimal obj-c/java boilerplate where methods are implemented in c++ directly (no need to expose it in obj-c/java) but it isn't set up to work with codegen yet (manual JSI setup).

See here for the library: https://github.com/animo/react-native-bbs-signatures

alon7 commented 2 years ago

Thanks for sharing, @TimoGlastra that's very cool. I also find the JNI/obj-c bindings a bit redundant, and it would be cool to try and call C++ directly. I didn't see a way with codegen to do so, but their documentation is not great, so there might be one. I can try to look at it, but I would also love if someone would try to take a stab at it.

ospfranco commented 2 years ago

Worst-case scenario one could use the turbo module to hoist an install step that installs pure C++ JSI bindings. At least until codegen supports generating pure C++.

Janaka-Steph commented 1 year ago

Can I ask an update on this? What is the right way to wrap a C library in a react native module today?

ospfranco commented 1 year ago

I read somewhere on twitter that C++ support was coming to Turbo Modules, no idea if it is out though

Janaka-Steph commented 1 year ago

Yes indeed but can't find any tutorial. Thanks anyway

ospfranco commented 1 year ago

https://www.youtube.com/channel/UCHxMuqeVlkDgKG5cs99FH2Q, somewhere in there the videos deal with async work and C++ bindings, can't remember which one. But this is off topic to this issue.