77

我整天都在用头撞桌子,试图解决这个问题!!!

我已经按照这里的建议尝试了建议xcode-select -switch /path/to/xcode/它仍然给我这个错误!

我现在已经完全删除了 XCode 4.4 和命令行工具,运行xcrun仍然给我这个错误!

即使安装新的 Xcode 副本和命令行工具也会产生这个错误!!

命令的结果..

sh-3.2# xcode-select -print-path
/Applications/Xcode.app/Contents/Developer
sh-3.2# xcrun -find
xcrun: Error: could not stat active Xcode path '/Volumes/Xcode/Xcode45-DP1.app/Contents/Developer'.           (No such file or directory)
4

7 回答 7

210

解决方案 #1(影响所有用户)

xcode-select是答案。您要么指向错误的路径,要么没有以 root 用户身份执行此操作。在终端试试这个:

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

然后输入您的密码。

解决方案 #2(仅影响您)

如果

  • 你不想sudo,或者
  • 您没有超级用户权限,或者
  • 解决方案#1不起作用

改写 DEVELOPER_DIR 环境变量:

export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"

可选:您可以通过编辑.bash_profile文件来使其在登录会话之间持续存在。

如果这两种解决方案都不起作用,请发布您的错误消息。

于 2012-08-15T18:40:59.150 回答
15

问题是它/usr/share/xcode-select/xcode_dir_link指向一个旧文件夹,并且在命令时不更新

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/被执行。

解决方案:删除此链接并手动创建。

于 2012-11-22T08:57:25.463 回答
7

这对我有用:

  1. XCode 首选项/位置/命令行工具 - 设置为正确的版本和位置
  2. XCode 首选项/下载 - 安装命令行工具
于 2012-09-21T17:17:48.303 回答
2

上面的解决方案对我没有帮助。删除旧系统链接对我有帮助。它在这里描述: 错误:无法运行/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/ibtool(没有这样的文件)

于 2013-11-25T19:01:00.133 回答
2

我会在 10.9 上出现同样的错误。我的系统上没有安装 XCode,我手动更新了 XCode 命令行工具。之后,以下命令为我修复了错误:

sudo xcode-select -switch /
于 2014-10-26T12:16:00.420 回答
1

我只在 mac 系统上看到过这种情况,因为它考虑运行很少的命令,例如gcc git系统级命令和command line developer tools.

卸载后我遇到了这个问题xcode。所以解决方案是要么安装xcode预先打包好的工具,要么只通过运行安装工具xcode-select --install

参考http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/

于 2018-11-13T08:19:01.957 回答
-11

最终奏效的解决方案是重新安装 10.8,重新安装 Xcode,然后重新安装命令行工具。

于 2012-08-27T15:11:04.600 回答