環境:macos 11.0.1
- 問題:安裝Homebrew異常
- 解決:執行替代命令
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
- 問題:XCode配置
- 解決:
- 選擇Command Line Tools
- 下載模擬器ios系統(可選個最小的)
- 選擇Command Line Tools
- 問題:執行
brew install cocoapods
提示github連接443 - 解決:
- 檢查修改本地git配置爲正確的github賬號(user.name 和 user.email)
- 刪除
~/.ssh
目錄下所有文件,使用命令重新生成ssh密鑰,再新建一個config
文件,內容如下
Host github.com User [email protected](Github賬號) Hostname ssh.github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Port 443
- 登錄github,填入ssh密鑰
- 執行
ssh -T [email protected]
,顯示Hi xxx! You've successfully ...
爲配置成功 - 重新執行
brew install cocoapods
- 問題:執行
npx react-native init AwesomeProject
安裝依賴時失敗,提示可以在項目ios目錄中手工執行pod install
。但手工執行失敗,都提示github 443超時錯誤。 - 解決:手工下載依賴包
- 打開
https://github.com/CocoaPods/Specs
下載zip包,然後解壓縮 - 打開
~/.cocoapods/repos
文件夾,新建master
文件夾 - 將解壓後的文件夾
Specs
和文件CocoaPods-version.xml
、README.md
拷貝至mater
文件夾 - 在master文件夾執行
git init
和git remote add origin https://github.com/CocoaPods/Specs
- 重新在項目的ios文件夾執行
pod install --verbose --no-repo-update
(可嘗試配合以下命令設置代理)
git config --global http.proxy "127.0.0.1:1080" git config --global https.proxy "127.0.0.1:1080"
- 執行完後再清除代理
git config --global http.proxy "" git config --global https.proxy ""
- 期間最後會有幾個包還需要下載,如果提示443,多試幾次
pod install
,直到所有包下載完
- 打開
- 問題:
yarn ios
編譯提示Build Commands Failed: PhaseScriptExecution...
- 解決:
- 刪除重新安裝yarn
brew uninstall --force yarn npm r -g yarn brew install yarn brew link yarn yarn -v
- 重新執行後成功
- 問題:運行成功打開ios模擬器後提示
No bundle URL present
- 解決:安裝switchhosts,配置host映射
127.0.0.1 localhost
成功運行效果
參考文章