ios原生项目集成reactnative步骤(RN学习一)

1、reactnative环境搭建(自行解决)
2、pods环境搭建(自行解决)
3、xcode新建工程RNTest
4、在项目工程根目录新建package.json,内容如下(具体需要哪些,根据项目配置,下面的内容是本人自己入门写的demo所用)
{
"name": "RNTest",(这是一个大坑,需要和工程名称相同,切记)
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"prop-types": "^15.6.0",
"react": "16.2.0",
"react-native": "0.52.1",
"react-native-deprecated-custom-components": "git+https://github.com/facebookarchive/react-native-custom-components.git",
"react-native-tab-navigator": "^0.3.4",
"react-native-xtabbar": "^0.2.1",
"react-navigation": "^1.0.0-beta.27"
},
"devDependencies": {
"babel-jest": "22.1.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.1.4",
"react-test-renderer": "16.2.0"
},
"jest": {
"preset": "react-native"
}
}
5、新建index.js,内容自行添加
-----到此reactnative相关配置结束---
6、新建Podfile文件(touch Podfile)
7、vim进入编写以下内容
//use_frameworks!OC项目不要加哦不然很爽
platform :ios, '8.0'
target 'RNTest' do
pod 'React', :path => '../RNTest/node_modules/react-native', :subspecs => [
'Core',
'ART',
'RCTActionSheet',
'RCTGeolocation',
'RCTImage',
'RCTNetwork',
'RCTPushNotification',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket',
'RCTLinkingIOS',
'DevSupport',//此处有坑,不加的话各种问题如:could not build module 'yoga',研究了2天时间,悲催
'BatchedBridge',//此处有坑,必须加
]
inhibit_all_warnings!//此处有坑,不要忘记添加,原因:内部数据转换精度问题,加上就行
pod 'yoga', :path => '../RNTest/node_modules/react-native/ReactCommon/yoga'//此处有坑 yoga必须全小写
end


8、npm install
9、pod install
【ios原生项目集成reactnative步骤(RN学习一)】10、大功告成

    推荐阅读