1乔询, 問(wèn)題: react-native run-ios報(bào)錯(cuò),Error watching file for changes: EMFILE
- 解決:
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
- 參考:
報(bào)錯(cuò)a
https://stackoverflow.com/questions/28225045/no-such-keg-usr-local-cellar-git
報(bào)錯(cuò)b
https://github.com/Homebrew/homebrew-core/issues/19286
2逢倍,問(wèn)題:No bundle URL present
解決:
方法---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ō)明】
- node升級(jí)參考:mac下nodejs 更新到最新版本的最新方法
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
解決:
你已經(jīng)上傳過(guò)同樣版本號(hào)的ipa凄吏,重新上傳需要修改版本號(hào)參考:
https://github.com/reactnativecn/react-native-pushy/issues/143
6, 問(wèn)題: npm install远舅,Error: Cannot find module 'semver'
- 解決:
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)
-
參考:
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
-
解決:
11,"OBJC_CLASS$_ RCTBridge", referenced from: objc-class-ref in MT AppController.o
思路: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.
解決:
12, The file “xxx” couldn’t be opened because you don’t have permission to view it
解決:
將info.plist 的 Bundle name As : (EXECUTABLE_NAME)
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生效全肮?
14,react-native run-ios 運(yùn)行報(bào)錯(cuò):Print: Entry, ":CFBundleIdentifier", Does Not Exist
解決方案1:改為sudo react-native run-ios (Xcode10下,并不能徹底解決問(wèn)題棘捣,能run success,但是不能安裝應(yīng)用到模擬器上)
參考:https://github.com/facebook/react-native/issues/14447解決方案2:
在項(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.
解決:
supportedOrientations={['portrait', 'landscape']}
文末提醒
其實(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
解決:
在RCTWebSocketExecutor.m文件中瞧毙,把localhost修改為與加載RN頁(yè)面http://xxx.xxx.xx.xx:8081/index.bundle?platform=ios
中相同的IP地址(一般為電腦IP).
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)題