When adding react native support to an existing iOS project, there are several key steps:
Create a new group in the project, and then node_modules
Locate React
and Libraries
two folders below to introduce the. xcodeproj file under the two folders into the group we created.
Locate the project build settings
configuration, Header Search Paths
Add an address below, navigate to the node_modules/react-native/React
directory, and select recursive ( recursive
).
Find the configuration of the project build phases
, locate Link Binary With Libraries
it, and complete the configuration by introducing the. A file in step 1.
Find the item's Other Linker Flags
configuration, add -ObjC
and -lc++
flag ?
In the introduction of Rctrootview, the official website of the code is a missing parameter, that is, the initialproperties parameter, we have to add this parameter in their own code, pass nil can be.
Fill in the module name inside the modulename, register the corresponding module name in JS
React native built-in API is not enough to meet all the requirements, and sometimes will write some of their own interface for JS call, the following list some points to note:
Because OC is multi-threaded (GCD), the above also said that when executing JavaScript is in the JavaScript thread, so when writing the interface, if you need to invoke the logic of non-JavaScript thread, you need to do in the main thread, That is, getting to the main thread before the business code is:
Dispatch_async (Dispatch_get_main_queue (), ^ { [nav pushviewcontroller:cg animated:yes]; });
4 in the custom interface, we defined in the OC end of the method, if there are parameters, then the JS end must pass this parameter, if not defined parameters, JS can not pass parameters, this May and JS past syntax is not the same, even if the definition of a method, I preach no error, but in OC is not, Must be passed in strict accordance with the format in which the method is defined.
React native integration into existing projects (non-cocoa pods)