RN——嵌入到iOS原生应用

1.在工程文件夹下,增加package.json文件,如下:

{
  "name": "RNTest1",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "react": "15.3.1",
    "react-native": "0.32.0"
  }
}

2.在工程文件夹下下载node_modules文件

$ npm install

3.使用cocoaPod下载需要的Subspaces
1)cd到工程文件下(.xcodeproj所在的文件夹中),执行以下命令创建Podfile文件

$ pod init

2)Podfile内容如下,可以根据需要添加其他subspecs

target 'RNTest1' do
  # Uncomment this line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for RNTest1

 pod 'React', :path => './node_modules/react-native', :subspecs => [
    'Core',
    'RCTText',
    'RCTNetwork’,
    'RCTWebSocket', # needed for debugging
    # Add any other subspecs you want to use in your project
  ]


end

3)使用cocoaPod下载

$ pod install

4.代码集成
1)在项目根目录下创建index.ios.js文件

$ touch index.ios.js

2)在需要的controller中,引入RCTRootView.h文件,使用

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值