且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将React Native应用程序嵌入现有的ios/android应用程序中

更新时间:2022-12-21 12:08:55

从您链接的文档中:

为了将React Native视图嵌入到本机组件中,我们使用 RCTRootView. RCTRootView是一个拥有React Native应用程序的UIView.它 还提供了本机端与托管应用之间的接口.

您可以生成一个包含此RCTRootView的iOS框架.如果您不想分发源代码,则应该能够分发二进制框架.

I need to know if it is possible to "embed" a react native app within an existing ios/android app without sharing the react native app code.

We currently have a react native app which use a few plugins dependencies and was asked if it would be possible to embed it within an existing native app (i.e. as a subview) and make both parts communicate with each other.

I know it is possible to do it (https://facebook.github.io/react-native/docs/communication-ios.html) but I'm rather wondering how to achieve it without sharing our current code with the existing app that needs our app to be embedded.

Is there any way to embed it as a bundle, a widget or even grab it from a private repo while building?

Thanks

From the documentation you linked:

In order to embed a React Native view in a native component, we use RCTRootView. RCTRootView is a UIView that holds a React Native app. It also provides an interface between native side and the hosted app.

You can produce an iOS Framework that includes this RCTRootView. You should be able to distribute the binary framework if you don't want to distribute the source.