如何从命令行更新Xcode

时间:2016-01-05 17:14:20

标签: xcode

我正在尝试从命令行更新Xcode。最初我试过跑:

 xcode-select --install

导致了这条消息:

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

所以问题仍然存在,有没有办法从命令行更新Xcode?

16 个答案:

答案 0 :(得分:170)

您实际使用的是安装Xcode命令行工具的命令 - void case3(int A[][MAXCOL]) // also works; does the same { } 。因此,您收到的错误消息 - 工具已经安装。

更新Xcode所需的命令是xcode-select --install。您可以使用softwareupdate command [args ...]查看可用内容,然后softwareupdate --list安装所有更新,或使用softwareupdate --install -a安装Xcode更新(如果可用)。您可以从list命令中获取名称。

正如评论中提到的heresoftwareupdate --install <product name>工具的手册页。

答案 1 :(得分:101)

我遇到了同样的问题,我通过以下方式解决了问题:

  1. 删除旧工具($ rm -rf /Library/Developer/CommandLineTools
  2. 再次安装xcode命令行工具($ xcode-select --install)。
  3. 完成这些步骤后,您将看到一个用于安装新版工具的pop。

答案 2 :(得分:26)

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

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

答案 3 :(得分:11)

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

答案 4 :(得分:6)

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

对于像我这样使用旧Mac Pro 5.1的用户,请注意。升级到Mojave需要安装金属gpu(我的情况下是蓝宝石AMD Radeon RX 560),但要确保只安装了HDMI监视器(不仅仅是4K!1080)。只有这样才安装Mojave说需要固件更新并关闭计算机。长2分钟的电源按钮保持不变,之后全部升级好了!

答案 5 :(得分:6)

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

答案 6 :(得分:5)

我试图将React-Native Expo应用程序与create-react-native-app一起使用,但是由于某些原因,它将启动我的模拟器,并且在不加载该应用程序的情况下挂起。上面ipinak的上述回答重置了Xcode CLI工具,因为尝试更新到最新的Xcode CLI无效。这两个命令是:

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

由于下载,此过程需要时间。 我将其保留在这里,否则将搜索该特定的React-Native Expo修复程序。

答案 7 :(得分:4)

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

这挽救了我的生活。 只需键入命令

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

答案 8 :(得分:3)

(使用xcode-select --install安装命令行工具后,键入:

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

您现在应该可以运行git:

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

答案 9 :(得分:2)

Xcode :: Install是一个简单的CLI软件,可让您安装/选择特定的Xcode版本。

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

切换版本

您可以在https://github.com/KrauseFx/xcode-install

中找到更多信息。

答案 10 :(得分:2)

你好,我是这样解决的:

安装应用程序> Xcode.app>目录>资源>程序包> XcodeSystemResources.pkg。

答案 11 :(得分:2)

我现在正在运行 OS Big Sur。 ${IfNot} ${AtLeastBuild} 9200 ... xcode-select --install 没有解决我的问题,推荐的后续 sudo xcode-select --reset 命令也没有解决我的问题。为了更好地衡量,我尝试了从 Apple 下载推荐的下载,但那里提供的命令行工具下载与我的操作系统不兼容。

我赞成为我解决的修复,softwareupdate --install -a 并为环境上下文添加了此帖子。

答案 12 :(得分:1)

对于那些在更新到Catalina之后遇到此问题的人,只需在终端上执行此命令

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

答案 13 :(得分:1)

我也遇到了同样的问题,请使用以下命令解决该问题。

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

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

/ Library / Developer / CommandLineTools

答案 14 :(得分:1)

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

<块引用>

appium-doctor --ios

...一堆东西...

警告 AppiumDoctor ✖ 运行 xcrun simctl 时出错

...一堆东西...

信息 AppiumDoctor ### 需要手动修复 ###

info AppiumDoctor 配置无法自动修复,请执行 先看:

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

就我而言

<块引用>

xcode-select -p

/Library/Developer/CommandLineTools

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

所以...

<块引用>

sudo xcode-select -r(需要 sudo)

然后...

<块引用>

xcode-select -p
/Applications/Xcode.app/Contents/Developer

此后,没有警告。 Appium-doctor 回来了。

答案 15 :(得分:0)

xCode版本11.2.1是在iPad 13.2.3中构建应用程序所必需的,当我直接尝试通过App Store从xcode 11.1升级到11.2.1时,它遭到了打击,因此经过一番研究,我找到了一个升级解决方案通过从系统中删除现有的xcode

因此,我在此处添加了卸载现有xcode后升级的步骤。

  
      
  1. 转到应用并识别Xcode并将其拖到垃圾箱。
  2.   
  3. 清空垃圾箱以永久删除Xcode。
  4.   
  5. 现在转到〜/ Library / Developer /文件夹并完全删除内容使用sudo rm -rf〜/ Library / Developer /避免任何   删除时出现权限问题
  6.   
  7. 最后删除~~ Library / Caches / com.apple.dt.Xcode路径中与xcode关联的所有缓存目录sudo rm -rf   〜/ Library / Caches / com.apple.dt.Xcode / *
  8.   
  9. 完成上述步骤后,您可以从App Store轻松安装xcode,它将安装最新版本的xcode
  10.   

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