1.搭建開發環境可參考 http://www.jianshu.com/p/c738dc11d867
2.然後使用xcode建立一個project檔案
3.在項目根目錄下建立 檔案夾如 : react
4.在react檔案夾下建立 package.json檔案
{
"name": "reactNativeTestProject”,//檔案名 "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "react": "16.0.0-alpha.6", "react-native": "^0.44.0" }, "devDependencies": { "babel-jest": "20.0.1", "babel-preset-react-native": "1.9.1", "jest": "20.0.1", "react-test-renderer": "16.0.0-alpha.6" }, "jest": { "preset": "react-native" } }
在react檔案夾下安裝react-native npm install
4.在根目錄下面建立Podfile檔案内容如下 platform :ios, '8.0' target 'reactNativeTestProject' do react_native_path = "./react/node_modules/react-native” #在podfile所在的目錄下找到node_modules檔案夾 pod "Yoga", :path => "#{ react_native_path}/ReactCommon/yoga" pod "React", :path => react_native_path, :subspecs => [ 'Core', 'RCTActionSheet', 'RCTAnimation', 'RCTGeolocation', 'RCTImage', 'RCTLinkingIOS', 'RCTNetwork', 'RCTSettings', 'RCTText', 'RCTVibration', 'RCTWebSocket' ] end
在根目錄下執行 pod install
關于報錯 No podspec found for `Yoga` in `./node_modules/react-native/ReactCommon/yoga/Yoga.podspec`
上邊的Podfile檔案中沒有添加 pod "Yoga", :path => "#{ react_native_path}/ReactCommon/yoga”,或者是該路勁不對
No podspec found for `React` in `../node_modules/react-native`
上邊的Podfile檔案中 pod "React", :path => react_native_path, :subspecs =>[ ];path可能不對