1.本文的前提条件是,电脑上已经安装了CocoaPods,React Native相关环境。
2.使用Xcode新建一个工程。EmbedRNMeituan
[图1]
3.使用CocoaPods安装React Native
在工程目录下新建Podfile文件,并配置需要使用的第三方库
pod 'React', '0.13.0-rc'
pod "React/RCTText"
pod "React/RCTActionSheet"
pod "React/RCTGeolocation"
pod "React/RCTImage"
pod "React/RCTLinkingIOS"
pod "React/RCTNetwork"
pod "React/RCTSettings"
pod "React/RCTVibration"
pod "React/RCTWebSocket"
platform :ios, '7.0'
注:如果你需要在React Native中使用<Text>,就需要添加
pod
"React/RCT
iOS项目集成React Native指南

本文介绍了如何在iOS原生项目中集成React Native。首先确保安装了CocoaPods和React Native环境,接着通过Xcode创建新工程。然后利用CocoaPods配置并安装React Native。在工程目录下建立Components文件夹和index.ios.js文件,编写必要代码。在集成过程中遇到了路径过长的错误以及服务器连接和安全问题。
最低0.47元/天 解锁文章
704





