ReactNative exposes native C ++ module

We have a lot of business logic written in cross-platform C ++. We want to write a cross-platform interface for our application and use this business logic to create an entire application with multiple platforms.

Is it possible to derive a native module written in C ++ native? We do not want to create wrappers around C ++ code in our native language (Java or Objective-C). Such wrappers will add more complexity, which will greatly complicate the process of debugging and research.

+4
source share
2 answers

I am also looking for a way to do this directly in C ++ without writing JNI for Android and Obj-C for iOS. I found the class CxxNativeModulein the corresponding source source. See an example implementation of SampleCxxModule .

The last thing to find out is how to register this module in C ++. In JNI for React Native Android implementation NativeModulesays

NativeModule, the implementation of which is written in C ++, should not provide any Java code (so that they can be reused on other platforms), but instead should be registered with CxxModuleWrapper.

Then the implementation CxxModuleWrappersays

This does nothing interesting except to eliminate the violation of existing code.

, . , , - CxxNativeModule, JS.

+3

, , os .

, , : ?

0

Source: https://habr.com/ru/post/1622183/


All Articles