Mac上調(diào)試React Native 0.57.8 問題集:
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ò)代理,從而需要繞道國外服務(wù)器,再去連接本地,所以無法正常訪問了?
解決辦法是:
暫時取消全局網(wǎng)絡(luò)代理,改為自動模式即可。
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選項
3.勾掉parallelize build
4.添加React編譯項,并移動到項目之前
Multiple configuration files found. Please remove one:
:-1: - package.json#babel
:-1: - .babelrc
配置babel時,兩個地方修改了,最終.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)試開發(fā)測試.
7.iphone真機上沒有熱加載選項..
8.mac開發(fā)android?
按官網(wǎng)安裝各種依賴軟件.
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ò),重新生成.
有時packerger啟動慢于模擬器,所以重新run就ok了.
11.Module AppRegistry is not a registered callable module
修改文件名時報錯,檢查后沒問題,重啟解決.
12.Failed to load Info.plist from bundle at path XXX
重啟解決.可能與android同時啟動,用同一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綁定去掉出錯.
15.task orphanded for request
用圖片緩存庫react-native-cached-image,暫未解決.
16.android 下text的value可以居中,IOS卻在頂上.
兩個平臺中text里的linespace不一樣.
...Platform.select({
ios:{
lineHeight:36,
},
android:{
}
})
17.undefined is not an object (evaluating '_this._setComponentRef.bind'
突然就啟動不了app了,真的突然就發(fā)生了..
又雙桑來.
查,是個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
正常了,該死,啥都沒動的.真的,我保證.!.
18.react link 后運行,有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編譯時,scheme中 Tests也需要設(shè)置development team ?關(guān)閉重新打開,編譯一遍過了..
21.其他機器上copy的工程,本機運行時報錯還是原來機器上的路徑,
--刪除ios下的build文件運行
22.PCH was compiled with module cache......
刪除ios下的build文件重新運行命令,或者xcode編譯運行
23.設(shè)置啟動圖片,替換新的無法顯示:
圖片不要放置在 images.xcassets 中,直接將圖片拖拽到項目目錄中,選擇copy item if need ,然后在設(shè)置這張圖片就可以了。
- 0.6 版本 打生產(chǎn)包時報錯
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工程,運行正常
- 打release包報錯,找不到main.jsbundle,
重新生成后,在xcode中加到原來的位置后可行.
另圖片等資源可能不能顯示,也需要拖進xcode.
react-native bundle --entry-file index.js --bundle-output ./ios/main.jsbundle --platform ios --assets-dest ./ios --dev false
26.在沒有網(wǎng)絡(luò)的情況下,原來正常的項目報錯.
No bundle URL present
且已經(jīng)打開的packger第二次也不能識別,總是會再啟動一個,并報端口占用錯誤.
解決:host文件中加localhost映射.