React Native報(bào)錯(cuò)問(wèn)題記錄(多種解決方案镰烧,持續(xù)更新)

1乔询, 問(wèn)題: react-native run-ios報(bào)錯(cuò),Error watching file for changes: EMFILE

Snip20180713_3.png
  • 解決:
 brew uninstall watchman
// 報(bào)錯(cuò)a 

brew uninstall --force watchman
brew cleanup --force -s watchman
brew prune
brew install watchman

// 報(bào)錯(cuò)b  Error: An unexpected error occurred during the `brew link` step The formula built, but is not symlinked into /usr/local Permission denied @ dir_s_mkdir - /usr/local/Frameworks Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

sudo mkdir /usr/local/Frameworks
sudo chown $(whoami):admin /usr/local/Frameworks

brew install watchman
react-native run-ios

2逢倍,問(wèn)題:No bundle URL present

Simulator Screen Shot - iPhone X - 2018-07-13 at 11.06.30.png
  • 解決:

  • 方法---1捧颅,(現(xiàn)在不管用)

Run "react-native run-ios"
When the error appears, run "npm install"
Then run "react-native run-ios" again.
check your hosts that 127.0.0.1    localhost is not delete
check that the network agent is not set up
then'npm install & react-native upgrade' to reset your project

3, The engine "node" is incompatible with this module (或Command yarn add react-native --exact failed.)

error react-native@0.56.0: The engine "node" is incompatible with this module
....
stderr: null,
stdout: null,
pid: 7395,
output: [ null, null, null ],
signal: null,
status: 1 }
Command yarn add react-native --exact failed.
  • 解決:
    更新node
### 第一步:使用npm安裝n模塊

* * *

n模塊是專門用來(lái)管理nodejs版本的

sudo npm install -g n

> **提示 :** 如果不使用sudo作為前綴较雕,很可能出現(xiàn)權(quán)限訪問(wèn)異常導(dǎo)致安裝失敗

### 第二步:升級(jí)nodejs

* * *

升級(jí)nodejs是有兩種方法: 
第一種是升級(jí)到最新版本

sudo n latest

第二種是升級(jí)到穩(wěn)定版本

sudo n stable

> **提示 :** 建議是穩(wěn)定版本 
> 更多n模塊管理請(qǐng)搜索【nodejs n模塊使用說(shuō)明】

4, TypeError [ERR_INVALID_CALLBACK]: Callback must be a function

$ pushy uploadIpa <your-package.ipa> 

當(dāng)我使用目前最新的 node 版本(10.x.x)時(shí)會(huì)報(bào)錯(cuò)

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at maybeCallback (fs.js:124:9)
    at Object.fs.write (fs.js:642:14)
    at /Users/www/admin/build/webpack.dev.config.js:12:8
    at FSReqWrap.oncomplete (fs.js:136:20)
  • 解決:
類似于這樣的錯(cuò)誤碉哑,這是因?yàn)?node 版本太高了,我們需要降級(jí)亮蒋,親測(cè)降到 v8.11.1 可行谭梗,不過(guò)我發(fā)現(xiàn)此 bug 在前兩天已經(jīng)被 react-native-update 的維護(hù)者修復(fù)了,如果依然碰到這個(gè)問(wèn)題宛蚓,可以試試此方法激捏。

5, 問(wèn)題: pushy uploadIpa xxx.ipa,Error: Validation error

6, 問(wèn)題: npm install远舅,Error: Cannot find module 'semver'

Snip20180802_16.png
  • 解決:
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --ignore-dependencies node
brew install node

7,問(wèn)題:'config.h' file not found

  • 解決:
$ rm -rf node_modules/ && yarn cache clean && yarn install
$ ls node_modules/react-native/ (missing third-party directory)

$ node_modules/react-native/ios-install-third-party.sh or node_modules/react-native/scripts/ios-install-third-party.sh
$ ls node_modules/react-native/ (third-party directory found)
  • 參考:


    Snip20180803_23.png

https://github.com/facebook/react-native/issues/14382

8, 集成react native到xcode痕钢,pod install 報(bào)錯(cuò)

~/Desktop/HuanXiangJiHua$ pod install
Analyzing dependencies
Fetching podspec for `CodePush` from `./ReactComponent/node_modules/react-native-code-push`
Fetching podspec for `DoubleConversion` from `./ReactComponent/node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `./ReactComponent/node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `React` from `./ReactComponent/node_modules/react-native`
Fetching podspec for `glog` from `./ReactComponent/node_modules/react-native/third-party-podspecs/glog.podspec`
Fetching podspec for `yoga` from `./ReactComponent/node_modules/react-native/ReactCommon/yoga`
[!] CocoaPods could not find compatible versions for pod "Folly":
  In Podfile:
    Folly (from `./ReactComponent/node_modules/react-native/third-party-podspecs/Folly.podspec`)

Specs satisfying the `Folly (from `./ReactComponent/node_modules/react-native/third-party-podspecs/Folly.podspec`)` dependency were found, but they required a higher minimum deployment target.
[!] Automatically assigning platform `ios` with version `8.0` on target `Unity-iPhone` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
  • 解決:
    問(wèn)題就在上面最后一句警告图柏。
    xcode項(xiàng)目使用的9.0和Folly的最低支持版本(9.0)不符.
    需將xcode版本改為最低支持9.0

tips:
查看Folly的最低支持版本——用文本編輯器打開./ReactComponent/node_modules/react-native/third-party-podspecs/Folly.podspe能看到其最低支持的版本

9, Failed to connect to 127.0.0.1 port 1080: Connection refused

pod install (或 pod update)

  • 報(bào)錯(cuò)信息
[!] Error installing Crashlytics
[!] /usr/bin/curl -f -L -o /var/folders/kz/p8_vcv1x0mn6x0wfmwy7z9d00000gn/T/d20180426-13131-1jlkxa7/file.zip https://kit-downloads.fabric.io/cocoapods/crashlytics/3.10.0/crashlytics.zip --create-dirs --netrc-optional

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to 127.0.0.1 port 1080: Connection refused

cocopods 導(dǎo)入庫(kù) 的時(shí)候時(shí)常被這個(gè)個(gè)錯(cuò)誤困擾,

  • 思路一:
    網(wǎng)上的解決辦法千篇一律任连,就是移除代理
    不過(guò)對(duì)我沒(méi)用蚤吹。還是給出這個(gè)方案,也許對(duì)你有效
查詢是否使用代理:git config --global http.proxy 
取消代理:git config --global --unset http.proxy
  • 思路二:
    下面給出對(duì)我有效的方案

找到自己本機(jī)賬號(hào)下面的.curlrc文件随抠,把它里面的 socks5 = "127.0.0.1:1080"insecure干掉

(注: 顯示隱藏文件(終端輸入 defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder)可以在finder本機(jī)賬戶看到隱藏文件 .curlrc)

ps:暫未出現(xiàn)副作用裁着,詳細(xì)原因后續(xù)查明更新
感謝:# Error installing Crashlytics - SSL peer handshake failed [closed]

10, 'React/RCTBridgeModule.h' file not found

  • 解決:


    Snip20180921_4.png

11,"OBJC_CLASS$_ RCTBridge", referenced from: objc-class-ref in MT AppController.o

Snip20180921_6.png

思路:pod install報(bào)的警告著手

[!] The `Unity-iPhone [Release]` target overrides the `OTHER_CFLAGS` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `Unity-iPhone [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `Unity-iPhone [Debug]` target overrides the `OTHER_CFLAGS` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `Unity-iPhone [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

解決:


Snip20180925_1.png

12, The file “xxx” couldn’t be opened because you don’t have permission to view it

13, npm install 白色進(jìn)度條卡住不動(dòng)拱她,安裝卡住

解決:
1二驰,??網(wǎng)上好多都是換鏡像(對(duì)我這次不行,那就不是鏡像的問(wèn)題)秉沼;
2桶雀,?刪除package-lock.json矿酵,node-modules,再執(zhí)行npm install,問(wèn)題解決(對(duì)我有效)矗积;

延伸:
為什么刪除package-lock.json生效全肮?


Snip20181022_13.png

14,react-native run-ios 運(yùn)行報(bào)錯(cuò):Print: Entry, ":CFBundleIdentifier", Does Not Exist

在項(xiàng)目文件夾下執(zhí)行:
第一步
cd node_modules/react-native/scripts && ./ios-install-third-party.sh && cd ../../../
第二步
cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh && cd ../../../../
??注意:第二步命令“golg-0.3.5”需要改成你的glog版本
可以在以下文件夾查看你的golg ( YourReactNativeProject ? ?node_modules? ? ?react-native? ? ?third-party?)
第三步重啟服務(wù):
npm start
參考: https://blog.csdn.net/chensenp/article/details/83543724

15倔矾,

Build input file cannot be found: 'xxx/double-conversion-1.1.5/src/strtod.cc'
  • 解決:
    cd node_modules/react-native/scripts && ./ios-install-third-party.sh && cd ../../../
    cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh

16,Error: fsevents unavailable (this watcher can only be used on Darwin)

  • 解決:
sudo chown -R whoami /usr/local
brew install watchman

17,Modal was presented with 0x0 orientations mask but the application only supports 0x18.Add more interface orientations to your app's Info.plist to fix this.NOTE: This will crash in non-dev mode.

文末提醒

其實(shí)react-native相關(guān)問(wèn)題多看看
https://github.com/reactnativecn/react-native-pushy/issues
還是能有效解決柱锹,網(wǎng)上搜還是比較浪費(fèi)時(shí)間

18,error: no type named 'NamedPropertyGetterCallback' in namespace 'v8'; did you mean 'IndexPropertyGetterCallback'?

  • 解決:

最近安裝realm的時(shí)候一直報(bào)這個(gè)錯(cuò)丰包,Google發(fā)現(xiàn)需要降級(jí)node到9.8.0

brew install npm
npm install -g node@9.8.0
brew install yarn

然后再執(zhí)行
npm install --save realm 就可以成功了

19禁熏,undefined is not a function (near '...a.Sync._initializeSyncManager...') 或者 realmConstructor.Sync._initializeSyncManager is not a function

  • 解決:
    node_modules/realm/lib/index.js里面 realmConstructor.Sync._initializeSyncManager(createUserAgentDescription());注釋掉
    然后打main.jsbundle,發(fā)布到code-push

realm用著有點(diǎn)蛋疼邑彪,打算后期換掉

參考:https://github.com/realm/realm-js/issues/2128

20, runtime is not ready for debugging

8bc6611e-893b-4449-b72f-4f0ed8fe9acc.jpg
  • 解決:
    在RCTWebSocketExecutor.m文件中瞧毙,把localhost修改為與加載RN頁(yè)面http://xxx.xxx.xx.xx:8081/index.bundle?platform=ios中相同的IP地址(一般為電腦IP).

  • 參考:
    http://www.reibang.com/p/90ceb04da552

21,init 命令默認(rèn)會(huì)創(chuàng)建最新的版本寄症,而目前最新的 0.45 及以上版本需要下載 boost 等幾個(gè)第三方庫(kù)編譯宙彪。這些庫(kù)在國(guó)內(nèi)即便翻墻也很難下載成功,導(dǎo)致很多人無(wú)法運(yùn)行iOS項(xiàng)目S星伞J推帷!`

  • 解決:
    中文網(wǎng)在論壇中提供了這些庫(kù)的國(guó)內(nèi)下載鏈接篮迎。如果你嫌麻煩男图,又沒(méi)有對(duì)新版本的需求,那么可以暫時(shí)創(chuàng)建0.44.3的版本甜橱。

提示:你可以使用--version參數(shù)(注意是個(gè)杠)創(chuàng)建指定版本的項(xiàng)目逊笆。例如react-native init MyApp --version 0.44.3。注意版本號(hào)必須精確到兩個(gè)小數(shù)點(diǎn)岂傲。

23难裆,failed to load bundle(http://127.0.0.1 xxxxxx) xxx could not connect to developer server

  • 解決:
    看iOS xcode中的日志得知是未允許http導(dǎo)致,xcode中配置一下ATS就好了镊掖。
    當(dāng)然你不一定是這個(gè)問(wèn)題
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末乃戈,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子亩进,更是在濱河造成了極大的恐慌偏化,老刑警劉巖,帶你破解...
    沈念sama閱讀 207,248評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件镐侯,死亡現(xiàn)場(chǎng)離奇詭異侦讨,居然都是意外死亡驶冒,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,681評(píng)論 2 381
  • 文/潘曉璐 我一進(jìn)店門韵卤,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)骗污,“玉大人,你說(shuō)我怎么就攤上這事沈条⌒璺蓿” “怎么了?”我有些...
    開封第一講書人閱讀 153,443評(píng)論 0 344
  • 文/不壞的土叔 我叫張陵蜡歹,是天一觀的道長(zhǎng)屋厘。 經(jīng)常有香客問(wèn)我,道長(zhǎng)月而,這世上最難降的妖魔是什么汗洒? 我笑而不...
    開封第一講書人閱讀 55,475評(píng)論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮父款,結(jié)果婚禮上溢谤,老公的妹妹穿的比我還像新娘。我一直安慰自己憨攒,他們只是感情好世杀,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,458評(píng)論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著肝集,像睡著了一般瞻坝。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上杏瞻,一...
    開封第一講書人閱讀 49,185評(píng)論 1 284
  • 那天湿镀,我揣著相機(jī)與錄音,去河邊找鬼伐憾。 笑死勉痴,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的树肃。 我是一名探鬼主播蒸矛,決...
    沈念sama閱讀 38,451評(píng)論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼胸嘴!你這毒婦竟也來(lái)了雏掠?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,112評(píng)論 0 261
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤劣像,失蹤者是張志新(化名)和其女友劉穎乡话,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體耳奕,經(jīng)...
    沈念sama閱讀 43,609評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡绑青,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,083評(píng)論 2 325
  • 正文 我和宋清朗相戀三年诬像,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片闸婴。...
    茶點(diǎn)故事閱讀 38,163評(píng)論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡坏挠,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出邪乍,到底是詐尸還是另有隱情降狠,我是刑警寧澤,帶...
    沈念sama閱讀 33,803評(píng)論 4 323
  • 正文 年R本政府宣布庇楞,位于F島的核電站榜配,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏吕晌。R本人自食惡果不足惜蛋褥,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,357評(píng)論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望聂使。 院中可真熱鬧,春花似錦谬俄、人聲如沸柏靶。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,357評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)屎蜓。三九已至,卻和暖如春钥勋,著一層夾襖步出監(jiān)牢的瞬間炬转,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,590評(píng)論 1 261
  • 我被黑心中介騙來(lái)泰國(guó)打工算灸, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留扼劈,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 45,636評(píng)論 2 355
  • 正文 我出身青樓菲驴,卻偏偏與公主長(zhǎng)得像荐吵,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子赊瞬,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,925評(píng)論 2 344

推薦閱讀更多精彩內(nèi)容