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

来源:互联网 发布:sql怎么定义一个变量 编辑:程序博客网 时间:2024/05/17 05:04

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 npmpod '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类库



0 0
原创粉丝点击