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

 xcode-select --install

这就产生了这条信息:

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

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


当前回答

这提醒了我为什么讨厌MacOS。每次我尝试这些错误之一,我都会得到一个无法理解的错误:无法请求安装(可能没有UI存在) 事实证明,这个“CLI”实际上需要一个图形会话才能运行。WTF !当你只通过SSH连接到远程mac服务器来排队iOS构建时,这非常有用。

所以我的答案是:

物理移动到Mac上,安装屏幕、鼠标和键盘,然后在那里运行命令。

其他回答

我在删除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

@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版本11.2.1对于在iPad 13.2.3中构建应用程序是必要的,当我直接尝试通过应用程序商店从xCode 11.1升级到11.2.1时,它被击中了,所以经过一些研究,我找到了一个解决方案,通过从系统中删除现有的xCode来升级

所以我在这里添加了卸载现有xcode后升级的步骤。

Go to Applications and identify Xcode and drag it to trash. Empty trash to permenently delete Xcode. Now go to ~/Library/Developer/ folder and remove the contents completely Use sudo rm -rf ~/Library/Developer/ to avoid any permission issue while deleting Lastly remove any cache directory associated with xcode in the path ~/Library/Caches/com.apple.dt.Xcode sudo rm -rf ~/Library/Caches/com.apple.dt.Xcode/* After completing the above steps you can easly install xcode from App Store, which will install the current latest version of xcode

注意:在进行上述更改之前,请备份现有项目

我试图使用React-Native Expo应用程序与create-react-native-app,但出于某种原因,它会启动我的模拟器,只是挂起而不加载应用程序。ipinak上面的答案重置Xcode CLI工具,因为试图更新到最新的Xcode CLI无法工作。这两条命令是:

rm -rf /Library/Developer/CommandLineTools
xcode-select --install

由于下载,这个过程需要时间。 我把这个留在这里,任何其他都会搜索这个特定的React-Native Expo修复。

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

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