一、安装ReactNative及code-push 1.安装rn项目依赖
新建文件夹foldername,在foldername下clone健客医院iOS项目及健客医院RN项目目录结构如下:
命令行进入RN项目根目录,执行npm install,安装node依赖模块。
2.安装iOS项目依赖
进入iOS项目文件夹,编辑Podfile文件,添加RN及code-push依赖:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# RN相关
pod 'React', :path => '../DoctorBonusPoints/node_modules/react-native', :subspecs => [
'Core',
'CxxBridge',
'RCTImage',
'DevSupport',
'RCTText',
'RCTNetwork',
'RCTWebSocket',
'RCTActionSheet',
'RCTLinkingIOS',
'RCTAnimation'
]
pod 'CodePush', :path => '../DoctorBonusPoints/node_modules/react-native-code-push'
pod 'RNGestureHandler', :path => '../DoctorBonusPoints/node_modules/react-native-gesture-handler'
pod 'yoga', :path => '../DoctorBonusPoints/node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../DoctorBonusPoints/node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../DoctorBonusPoints/node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../DoctorBonusPoints/node_modules/react-native/third-party-podspecs/Folly.podspec'
打开命令行,在iOS项目根目录下执行pod install,安装成功后。打开iOS项目,手动删除Pods target下的Development Pods文件夹内的React文件夹,也就是删除刚刚安装的RN的依赖库。去github下载CRN开源项目,下载成功后解压,文件结构如下:
将CRN文件夹和ReactNative文件夹拷贝到健客医院项目的JianKeDoctor目录下。打开健客医院iOS项目添加文件夹下子工程依赖如图所示:
点击xode 左上角项目target,选择 edit scheme如图所示,点击build选项卡,点击加号添加React编译依赖,取消勾选parallelize选项,注意要把React放在最上边使之先编译。
进入工程的buildphases添加library
点击build settings选项卡,找到Header Search Paths选项,添加搜索路径
1
2
${SRCROOT} /JianKeDoctor/RNLib/ReactNative
${SRCROOT} /JianKeDoctor/CRN
搜索路径都设置为recursive,递归查找。
到此安装工作结束。
more >>