升級 Xcode 12 之一連串的坑 😅. 但為了避免升級到一半死機或其他狀況，建議預留20GB的儲存容量，且使用時光機備份…
By: Kiki Art
Tags: Macos Big Sur, Xcode 12, Xcode

原本Mac OS為Mojave 要升級xcode12 ，勢必是一定要先升級Mac OS，但為了避免過程中死機或其他狀況，建議預留20GB的儲存容量，且使用時光機備份電腦(第一次使用時光機會需要比較多時間，大概5–7小時，視使用狀況做增減)

確認備份檔案無問題後，可以開始升級OS了

請前往Mac的”系統偏好設定”中的”軟體更新”檢查最新版本並點擊”立即更新”

Mac會開開關關很多次 且更新及安裝時間要抓個一個小時以上

此次更新的OS版本為Mac OS Big Sur

但與前一版(Mac OS Catalina)一樣都停用32位元的app了(可以在”關於這台mac”中的”系統報告”裡的”已停用的軟體”中看到)

更新完畢後

可以先更新xcode 因為一樣要下載安裝很久….

確認安裝沒問題後，

我們要來除坑了….

首先

新版的Mac OS 的Terminal預設shell 改為 zsh (原為bash)

在你突然想排除xcode錯誤的時候 一定會想先排除第三方套件的錯誤

這時候因為預設更換的關係 cocoapods 失效了…

連續更新了2台mac後 ，得出了以下sop，請在Terminal中依序輸入：

首先 把shell改為zsh

chsh -s /bin/zsh

接著確認ruby版本

ruby -v

確認rvm版本

rvm -v

列出rvm中目前有哪些可以安裝的列表

rvm list known

設定環境變數的路徑

source ~/.bashrc source ~/.bash_profile

安裝最新的ruby版本(版本號請依據所列出來的最新版號做調整)

rvm install 2.7.0-preview1

==> Downloading and installing Homebrew…

xcrun: error: active developer path (“/Users/XXX/Desktop/Xcode.app/Contents/Developer”) does not exist Use `sudo xcode-select — switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select — install` to install the standalone command line developer tools. See `man xcode-select` for more details. Failed during: git init -q Requirements installation failed with status: 1.

若出現xcode路徑的報錯，重新設定路徑

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

若出現以下錯誤：

Failed to update Homebrew, follow instructions at https://docs.brew.sh/Common-Issues and make sure `brew update` works before continuing. Error running ‘requirements_osx_brew_update_system ruby-2.6.0-preview2’, please read /Users/XXX/.rvm/log/1607656059_ruby-2.6.0-preview2/update_system.log Requirements installation failed with status: 1.

要先更新brew

brew update

更新brew update時若出現

Error: homebrew-core is a shallow clone. To `brew update` first run: git -C “/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core” fetch — unshallow This restriction has been made on GitHub’s request because updating shallow clones is an extremely expensive operation due to the tree layout and traffic of Homebrew/homebrew-core. We don’t do this for you automatically to avoid repeatedly performing an expensive unshallow operation in CI systems (which should instead be fixed to not use shallow clones). Sorry for the inconvenience!

從git 更新homebrew-core

git -C “/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core” fetch — unshallow

再次更新brew

brew update

更新brew時若出現

Error: homebrew-cask is a shallow clone. To `brew update` first run: git -C “/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask” fetch — unshallow This restriction has been made on GitHub’s request because updating shallow clones is an extremely expensive operation due to the tree layout and traffic of Homebrew/homebrew-cask. We don’t do this for you automatically to avoid repeatedly performing an expensive unshallow operation in CI systems (which should instead be fixed to not use shallow clones). Sorry for the inconvenience!

從git 更新homebrew-cask

git -C “/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask” fetch — unshallow

再更新brew

brew update

再次安裝最新的ruby版本

rvm install 2.7.0-preview1

再次檢查ruby版本，是否為剛剛安裝的版本

ruby -v

使用gem安裝cocoapods

sudo gem install cocoapods

確認cocoapods是否設定完成

pod setup

若出現下列錯誤：

zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory

請更新gem

sudo gem update — system

使用gem安裝cocoapods 於/usr/local/bin

sudo gem install cocoapods -n /usr/local/bin

若出現cannot load such file — rubygems-bundler/noexec (LoadError) 需解除安裝 rubygems-bundler

gem uninstall -i /Users/XXX/.rvm/rubies/ruby-2.7.0-preview2/lib/ruby/gems/2.7.0 rubygems-bundler

出現Successfully uninstalled rubygems-bundler-1.4.5即成功

確認cocoapods是否設定完成