Background: Recently, I wanted to add ReactNative to existing projects, but I didn’t want to put existing projects in the IOS/Andriod folder of RN’s project directory as the official documentation solution, which felt awkward and inflexible. So think of an RN project as a module imported into the project via POD.

This article only attempts to introduce another project into an existing project

The subjects had two items: BBB and AAA

Among them, BBB uses workspace+ POD to manage the third party. A is A simple project, which is the purest state.

Project B uses CocoaPods+workspace to manage the project. A is an independent project to manage it, and now I want to introduce A into B. This experiment was done last night, using Swift

The two projects are structured as follows

Open the workspace of project B, right-click in the left workspace and choose Add Files to “BBBTest”, as shown in the figure:

Select A’s project file and import A into B

Create A new framwork Target in A and add the files that need to be exposed to Compil Sources under Build Phases

Note that the SWIFT file exposed in A is not in the same module as the SWIFT file in B, so it needs to add the public modifier, otherwise it cannot be used in B

After the operation is completed, the project directory structure is as follows, AAATest, BBBTest and Pods are in parallel state, as shown in the figure below

Finally, we can use the AAAViewController exposed in project A in project B

The running effect is as follows:

Click Go A to jump to the page of PROJECT A

This is done, providing ideas for the introduction of The React-Native project in the following existing projects. We also hope that you can provide other better ideas for common progress.