Integrated reactnative to existing iOS projects

Source: Internet
Author: User

A while ago just contacted Reactnative, feel good. Today's whim to share this article to everyone, OK let's go straight to the topic!

1. Build reactnative development base environment can be configured according to http://reactnative.cn/docs/0.31/getting-started.html documentation, install the necessary tools

2. Create an iOS project TESTRTC

3. Go to the project root directory to perform the installation reactnative command line tool NPM Install-g REACT-NATIVE-CLI

4. Create a React folder under the project's root directory to hold the relevant files for RN

5. Create a Package.json file under the React folder to initialize the RN (the Package.json in this case is best to copy it in the initialization of a project to ensure the latest react, reactnative version, Initialize the project command react-native Init awesomeproject), the name in Package.json is the same as the name in the iOS project: "Name": "TESTRTC"

6. Install the reactnative dependency package into the React directory to perform NPM install

7. After successful installation, create index.ios.js (under the React directory), you can copy it from the initialized Awesomeproject project above (but the project name in Index.ios.js should correspond to the same name as your iOS project).

8. Use Cocoapods to automatically integrate reactnative to create podfile files in the project's root directory

The Pod file contents are

Target ' TESTRTC ' do

Pod ' React ',:p ath = './reactcomponen/node_modules/react-native ',: Subspecs = [

' Core ',

' ART ',

' Rctactionsheet ',

' Rctadsupport ',

' Rctgeolocation ',

' Rctimage ',

' Rctnetwork ',

' Rctpushnotification ',

' Rctsettings ',

' Rcttext ',

' Rctvibration ',

' Rctwebsocket ',

' Rctlinkingios ',

]

End

9. Then perform pod install--verbose--no-repo-update installation

10. After the completion of the above steps after the integration of RN to the project has been done, see how to apply RN in Xcode

Create a controller, code such as

Now it's time to run Xcode.

11. After running to jump from OC to the RN interface will appear red screen, this time do not panic, look carefully after the error you will find that the NPM service is not up, and then in the console into the react directory to execute the NPM start command, When you re-run the project, you'll find that the Reactnative interface can be displayed in front of us.

12.ok accomplished

Integrated reactnative to existing iOS projects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.