Brew 升级不适用于最新的 OSX High Sierra 测试版

Brew upgrade not working on latest OSX High Sierra beta version

升级 brew 包时出现以下错误

Error: Your Xcode (8.3.3) is too outdated.
Please update to Xcode 9.0 (or delete it).
Xcode can be updated from
https://developer.apple.com/download/more/

因为我使用的是 beta osx 版本

High Sierra
System Version: macOS 10.13
Kernel Version: Darwin 17.0.0

看来我也必须升级测试版Xcode版本(Xcode 9),我已经从苹果网站下载并安装成功https://developer.apple.com/xcode/

现在,我的问题是如何在 mac 上切换 Xcode 版本,以便 brew 命令使用新安装的 Xcode.

当我 运行 xcodebuild -version 我得到以下输出(从 App store 安装)

Xcode 8.3.3
Build version 8E3004b

而我下载的测试版是苹果官网直接显示9.0 beta 6

由于 Xcode 是从网站下载的,因此完整的切换命令如下(考虑到您已将应用程序移动到应用程序文件夹)

sudo xcode-select --switch /Applications/Xcode-beta.app

我不得不重新安装 brew:

卸载它:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

然后就可以重新安装了:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"