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

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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值