您的位置:首页 > Web前端 > React

ReactNative与现有的iOS应用程序集成

2016-01-28 12:26 351 查看
1.安装CocoaPods

2.安装Node.js

3.在要集成ReactNative项目的根目录下安装react-native:

npm install react-native

如果成功的话,项目的根目录下就会出现node_modules文件夹

4在项目的根目录下新建一个名为Podfile的文件,打开文件,填入下面的文本:

# Depending on how your project is organized, your node_modules directory may be
# somewhere else; tell CocoaPods where you've installed react-native from npm
pod 'React', :path => './node_modules/react-native', :subspecs => [
'Core',
'RCTImage',
'RCTNetwork',
'RCTText',
'RCTWebSocket',
# Add any other subspecs you want to use in your project
]


5.执行命令:

pod install


6.在项目的根目录下创建一个名称为ReactComponent的文件夹:

mkdir ReactComponent


执行完之后创建一个名称为index.ios.js的文件:

touch ReactComponent/index.ios.js
在index.ios.js的文件中填入要执行的js代码即可。

7.请参考官方文档:点击打开链接

8.注意事项:项目中一定要添加libReact.a类库
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios mac xcode