Mac上調(diào)試React Native 0.57.8 問(wèn)題集:
IOS:
1.Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
是由于:
(shadowsocks的)網(wǎng)絡(luò)代理設(shè)置為了全局代理(去翻墻)
-》導(dǎo)致了之前可以正常連接到本地的packager的server,由于全局網(wǎng)絡(luò)代理痘拆,從而需要繞道國(guó)外服務(wù)器仰禽,再去連接本地,所以無(wú)法正常訪問(wèn)了错负?
解決辦法是:
暫時(shí)取消全局網(wǎng)絡(luò)代理坟瓢,改為自動(dòng)模式即可。
2.Support for the experimental syntax 'decorators-legacy' isn't currently enabled (232:1):
修改.babelrc(新版本已經(jīng)改名字了,內(nèi)容一樣)文件如下,解決:
{
"presets": ["module:metro-react-native-babel-preset"],"plugins": [ [ "@babel/plugin-proposal-decorators", { "legacy": true } ] ]
}
3.Libraries/LinkingIOS/RCTLinkingManager.h:10:9: 'React/RCTEventEmitter.h' file not found
1.快捷鍵command+shift+<
2.選中build選項(xiàng)
3.勾掉parallelize build
4.添加React編譯項(xiàng),并移動(dòng)到項(xiàng)目之前
Multiple configuration files found. Please remove one:
:-1: - package.json#babel
:-1: - .babelrc
配置babel時(shí),兩個(gè)地方修改了,最終.babelrc文件生效,去掉package.json中#babel的配置
5.nw_connection_get_connected_socket_block_invoke Connection has no connected handle解決辦法
1. Xcode menu -> Product -> Edit Scheme...
2. Environment Variables -> Add -> Name: "OS_ACTIVITY_MODE", Value:"disable"
3. Run your app again, done!
6.scheme的作用?
用于各種環(huán)境版本調(diào)試開(kāi)發(fā)測(cè)試.
7.iphone真機(jī)上沒(méi)有熱加載選項(xiàng)..
8.mac開(kāi)發(fā)android?
按官網(wǎng)安裝各種依賴(lài)軟件.
9.Print: Entry, ":CFBundleIdentifier", Does Not Exist
1.rm -rf node_modules && rm -rf ~/.rncache && yarn
2.npm install
3.react-native upgrade
10.Make sure you’re running a packager server or have included a .jsbundle file in your application bundle
關(guān)閉 packager, 斷掉網(wǎng)絡(luò),重新生成.
有時(shí)packerger啟動(dòng)慢于模擬器,所以重新run就ok了.
11.Module AppRegistry is not a registered callable module
修改文件名時(shí)報(bào)錯(cuò),檢查后沒(méi)問(wèn)題,重啟解決.
12.Failed to load Info.plist from bundle at path XXX
重啟解決.可能與android同時(shí)啟動(dòng),用同一packager有關(guān).
13.RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
14.Cannot update during an existing state transition (such as within render
). Render methods should be a pure function of props and state
this綁定去掉出錯(cuò).
15.task orphanded for request
用圖片緩存庫(kù)react-native-cached-image,暫未解決.
16.android 下text的value可以居中,IOS卻在頂上.
兩個(gè)平臺(tái)中text里的linespace不一樣.
...Platform.select({
ios:{
lineHeight:36,
},
android:{
}
})
17.undefined is not an object (evaluating '_this._setComponentRef.bind'
突然就啟動(dòng)不了app了,真的突然就發(fā)生了..
又雙桑來(lái).
查,是個(gè)bug...
1.添加babel-plugin-transform-flow-strip-types,
2.babelrc加上
"plugins": [
["@babel/plugin-transform-flow-strip-types"],
3.重啟模擬器
4.react-native start --reset-cache
5.react-native run-ios
正常了,該死,啥都沒(méi)動(dòng)的.真的,我保證.!.
18.react link 后運(yùn)行,有error,重復(fù)加載字體文件,需要在xcode里清除重復(fù)的文件.
19.PCH was compiled with module cache path '/Users/...' but the path is currently '...'
刪除build/ModuleCache文件犹撒,然后重新執(zhí)行:
Signing for "AwesomeProjectTests" requires a development team. Select a development team in the project editor. (in target 'AwesomeProjectTests')
xcode編譯時(shí),scheme中 Tests也需要設(shè)置development team ?關(guān)閉重新打開(kāi),編譯一遍過(guò)了..
21.其他機(jī)器上copy的工程,本機(jī)運(yùn)行時(shí)報(bào)錯(cuò)還是原來(lái)機(jī)器上的路徑,
--刪除ios下的build文件運(yùn)行
22.PCH was compiled with module cache......
刪除ios下的build文件重新運(yùn)行命令,或者xcode編譯運(yùn)行
23.設(shè)置啟動(dòng)圖片,替換新的無(wú)法顯示:
圖片不要放置在 images.xcassets 中商叹,直接將圖片拖拽到項(xiàng)目目錄中,選擇copy item if need 洋腮,然后在設(shè)置這張圖片就可以了阔逼。
- 0.6 版本 打生產(chǎn)包時(shí)報(bào)錯(cuò)
Undefined symbols for architecture arm64:
"_RCTSetLogFunction", referenced from:
-[bookmanagerTests testRendersWelcomeScreen] in bookmanagerTests.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
刪除test工程,運(yùn)行正常
- 打release包報(bào)錯(cuò),找不到main.jsbundle,
重新生成后,在xcode中加到原來(lái)的位置后可行.
另圖片等資源可能不能顯示,也需要拖進(jìn)xcode.
react-native bundle --entry-file index.js --bundle-output ./ios/main.jsbundle --platform ios --assets-dest ./ios --dev false
26.在沒(méi)有網(wǎng)絡(luò)的情況下,原來(lái)正常的項(xiàng)目報(bào)錯(cuò).
No bundle URL present
且已經(jīng)打開(kāi)的packger第二次也不能識(shí)別,總是會(huì)再啟動(dòng)一個(gè),并報(bào)端口占用錯(cuò)誤.
解決:host文件中加localhost映射.