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

 xcode-select --install

这就产生了这条信息:

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

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


当前回答

我在删除Xcode后得到这个错误。我通过使用sudo xcode-select -r重置命令行工具路径来修复它。

之前:

navin@Radiant ~$ /usr/bin/clang
xcrun: error: active developer path ("/Applications/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.

navin@Radiant ~$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

后:

navin@Radiant ~$ /usr/bin/clang
clang: error: no input files

其他回答

我遇到了同样的问题,使用下面的命令解决了它。

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

运行上述命令后,xcode-select -p命令显示如下内容。

/图书馆/开发/ CommandLineTools

@Vel Genov的回答是正确的,除非Xcode的版本无法更新,因为它是当前Mac OS的最新版本。如果你知道有更新的Xcode(例如,它不会将应用加载到最新版本的iOS设备上),那么有必要先升级Mac OS。


对于像我这样使用旧Mac Pro 5.1的人来说,还有一点值得注意。升级到Mojave需要安装金属gpu(蓝宝石AMD Radeon RX 560在我的情况下),但确保只安装HDMI监视器(不是4K!1080只)。然后才安装Mojave说固件更新需要关闭电脑。长2分钟的电源按钮保持,它都升级好之后!


如果有一个挂起的更新,install -a不会从命令行升级xcode(假设你选择了隔夜更新xcode)

我在删除Xcode后得到这个错误。我通过使用sudo xcode-select -r重置命令行工具路径来修复它。

之前:

navin@Radiant ~$ /usr/bin/clang
xcrun: error: active developer path ("/Applications/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.

navin@Radiant ~$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

后:

navin@Radiant ~$ /usr/bin/clang
clang: error: no input files

只要输入命令

cd  /Library/Developer/CommandLineTools/Packages/;
open macOS_SDK_headers_for_macOS_10.14.pkg

参考:https://forums.developer.apple.com/thread/104296

我是来安装Appium的。加上我的答案,以防其他人在这里遇到同样的问题。

ios appium-doctor——

... 一堆东西…

WARN AppiumDoctor 4运行xcrun simctl错误

... 一堆东西…

需要手动修复的问题

AppiumDoctor配置无法自动修复,请执行 第一:

警告AppiumDoctor➜手动安装Xcode,并确保“Xcode -select -p”命令显示正确的路径,如“/Applications/Xcode.app/Contents/Developer”

对我来说

xcode-select - p

/图书馆/开发/ CommandLineTools

这似乎是错误的……但我知道我最近更新了Xcode和命令行工具

所以…

Sudo xcode-select -r (Sudo必需)

然后……

xcode-select - p /应用程序/ xcode /内容/开发人员

在此之后,没有任何警告。阿普医生干净利落地回来了。