Registering a Pure C++ Native Module within a library #286
-
Hi, I've successfully followed the documentation on pure C++ modules and I am trying to create a library, which exposes a pure C++ module. The reason for needing a pure C++ module is that I want to use the However, I'm struggling when trying to migrate this to a library. The library project create-react-native-library doesn't support pure C++ modules rather the C++ template is implemented in Kotlin/Objective-C and then calls into shared C++ code and they have recently dropped this template callstack/react-native-builder-bob#818. iOS I did somewhat get that working, it called into my pure C++ implementation but then crashed with the error ![]() I have a sample project that should reproduce the error using this commit d9a8cbe.
As a side question, does the consuming app also need to be running I did get iOS working by registering the C++ turbo module in the consuming app's However, ideally I don't want the consumer of my library to need to concern themselves with this code, the library should be able to register the module for them. Android However, I've been unable to utilise this approach from a library. I have tried including the Is it just a case of the consuming app needing to register my module for me? Or how is best to approach this situation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I came across this video https://www.youtube.com/watch?v=KURIqiCPbco and in there they used an Objective-C file with a |
Beta Was this translation helpful? Give feedback.
Ah I have also implemented it on Android using the same author's video for Android: https://www.youtube.com/watch?v=ibgHObp8YwA&t=8s. This commit 79aa951 demonstrates it.
In particular not registering the module within the
<name>Package.kt
file but instead adding to thereact-native.config.js
file the values forcxxModuleCMakeListsModuleName
,cxxModuleCMakeListsPath
&cxxModuleHeaderName
, which I think is documented in the autolinking docs.