react-native 版本問(wèn)題
搭建react native開發(fā)環(huán)境妹蔽,最正確的肯定是官方文檔材鹦,按照現(xiàn)在0.61版本的文檔開說(shuō)碟狞,node 版本不得低于10.0.0可都。 由于之前項(xiàng)目用過(guò)的都是0.55.3的版本缓待,現(xiàn)在換為0.61肯定會(huì)有一系列其他改動(dòng)。
Could not find iPhone 6 simulator
xcode10.~版本基本不存在次問(wèn)題渠牲,
xcode 11.0 - 11.3
進(jìn)入項(xiàng)目工程目錄下(找到這個(gè)findMatchingSimulator.js 并修改)
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
```
/* 修改 simulators 的判斷*/if(!version.startsWith('iOS')&&!version.startsWith('tvOS')){continue;}/*修改成如下*/if(!version.includes('iOS')){continue;}
```
xcode 11.3及以上
```
/* 修改 simulators 的判斷*/if (!version.startsWith('iOS') && !version.startsWith('tvOS'))/*修改成如下*/if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))
/* 修改 simulators 的判斷*/simulator.availability !== '(available)')/*修改成如下*/simulator.isAvailable !== true
```
參考1?http://www.reibang.com/p/1df787ab33e6
參考2?http://www.reibang.com/p/9f815533efb8
xcode11報(bào)錯(cuò)旋炒,解決方案:
路徑: 項(xiàng)目/node_modules/react-native/React/Base/RCTModuleMethod.mm. (或者.m)文件
找到 static BOOL RCTParseUnused 這個(gè)方法
替換成
```
static BOOL RCTParseUnused(const char **input)
{
? return RCTReadString(input, "__unused") || RCTReadString(input, "__attribute__((__unused__))") ||?RCTReadString(input, "__attribute__((unused))");
}
```
簡(jiǎn)單講,就是一個(gè)依賴下載不下來(lái)签杈。
cd?~/.rncache
有4個(gè)文件
沒有的国葬,去網(wǎng)上找一下,下載丟到這個(gè)文件夾里去
參考https://www.cnblogs.com/junhuawang/p/7573681.html
React Native undefined is not an object (evaluating 'this.onPressButton.bind')
添加 @babel/plugin-transform-flow-strip-types 依賴
在babel.config.js文件中增加
{ "plugins": [ ['@babel/plugin-transform-flow-strip-types']]}
react-native-fetch-blob 最后一次維護(hù)是在17年8月3號(hào),已經(jīng)沒人維護(hù)升級(jí)了汇四。
webview的替換
老版本import { webview } from 'react' ,新版本需要另行安裝?react-native-webview,?import { webview } from?react-native-webview.
同時(shí)踢涌,webview向rn通訊由window.postMessage 變更為window.ReactNativeWebView.postMessage
html對(duì)rn向webview傳遞事件的監(jiān)聽需要分ios和android端通孽,ios使用window.addEventListener android使用document.addEventListener