常用環(huán)境
vs code插件
- Debugger for Chrome (裝完記得配置launch.json文件)
- React Native Tools
- 配置相對引用路徑
中文教程文檔
https://reactnative.cn/docs/getting-started.html
新建項目
react-native init <項目名稱> --version <指定版本號>
react-native init MyApp --version 0.44.3
react-native init MyApp (默認使用最新版)
運行指令
react-native run-ios
react-native run-android
工程報錯常用
重新連接設置第三方庫
cd ./node_modules/react-native/third-party/glog-0.3.4
sh ../../scripts/ios-configure-glog.sh
重新連接設置第三方庫
cd ./node_modules/react-native/third-party/glog-0.3.4
../../scripts/ios-configure-glog.sh
安裝缺失的庫
//安裝缺失的庫
yarn add react-native-qiyu
//link
react-native link react-native-qiyu
踩坑實戰(zhàn)指南
先導出行(iOS)
// 1. 安裝
npm install
//2. 重新鏈接,設置庫
cd ./node_modules/react-native/third-party/glog-0.3.4
sh ../../scripts/ios-configure-glog.sh
//3 . websocket 依賴庫欠缺
復制一份libfishhook.a(可從工程RCTWebSocket.xcodeproj的products找到) 到 node_modules/react-native/Libraries/WebSocket/
- 如果Xcode 某些子工程沒編譯好(子工程無法展開), 可以先把 build文件夾刪掉,然后執(zhí)行
react-native run-ios
- 如果使用本機ip debug運行,程序可進入, 但報 ip無法讀取,可執(zhí)行
npm start -- --reset-cache
//4. appdelegate.mm的index.ios.bundle修改為 index.bundle
jsCodeLocation = [NSURL URLWithString:@"http://192.168.50.85:8081/index.bundle?platform=ios&dev=true"];
//5. copy svn上修改過的庫
不要復制 react-native-code-push ,