我正在尝试从命令行更新Xcode。一开始我试着跑步:

 xcode-select --install

这就产生了这条信息:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

那么问题来了,有没有办法从命令行更新Xcode呢?


当前回答

当我卸载完整版本的Xcode以重新安装CLI版本时,我遇到了同样的问题。我的解决方案是:

sudo xcode-select -s /Library/Developer/CommandLineTools

其他回答

Xcode::Install是一个简单的命令行软件,允许你安装/选择特定的Xcode版本。

您可以使用gem install xcode-install安装它 然后,您将能够使用xcversion install 9.4.1安装特定的版本 如果您安装了多个版本,则可以使用xcversion select 9.4切换版本

你可以在https://github.com/KrauseFx/xcode-install上找到更多信息

当我卸载完整版本的Xcode以重新安装CLI版本时,我遇到了同样的问题。我的解决方案是:

sudo xcode-select -s /Library/Developer/CommandLineTools

我现在运行OS大苏尔。Xcode-select——install,和sudo Xcode-select——reset没有解决我的问题,也没有推荐后续的软件更新——install -a命令。除此之外,我还尝试了从Apple Downloads下载的推荐下载,但那里可用的命令行工具下载与我的操作系统不兼容。

我对为我解决的修复方案进行了投票,sudo xcode-select——switch /Library/Developer/CommandLineTools/,并添加了这篇文章用于环境上下文。

在安装命令行工具(使用xcode-select——install)后,输入:

sudo xcode-select --switch /Library/Developer/CommandLineTools/

你现在应该可以运行git了:

10:29 $ git --version
git version 2.17.2 (Apple Git-113)

我也遇到过同样的问题,我采取了以下方法:

删除旧的工具($ sudo rm -rf /Library/Developer/CommandLineTools) 重新安装xcode命令行工具($ xcode-select——Install)

完成这些步骤后,您将看到一个弹出窗口来安装新版本的工具。