8

Mac OS X 10.8.2
Xcode 4.5.2(安装在 /Applications/Xcode.app)

尝试
xcode-select -switch /Applications/Xcode.app
之后
xcode-select -print-path
输出正确的路径(/Applications/Xcode.app)。但因
xcrun -find gcc
错误
xcrun 失败:错误:无法统计活动 Xcode 路径“/Developer/Xcode.app/Contents/Developer”。(没有这样的文件或目录)。

更新 1:
这里是权限说明符

ls -l /Applications/Xcode.app  

总计 0
drwxr-xr-x@ 16 我的管理员 544 Oct 30 23:38 内容

ls -l /Applications/Xcode.app/Contents  

总计 24
drwxr-xr-x@ 8 我的管理员 272 10 月 30 日 23:30 应用程序
drwxr-xr-x@ 9 我的管理员 306 10 月 30 日 23:36 开发人员
drwxr-xr-x@ 5 我的管理员 170 10 月 30 日 23:30 框架
-rw-r--r--@ 1 我的管理员 15289 10 月 19 日 14:22 Info.plist
drwxr-xr-x@ 3 我的管理员 102 8 月 5 日 08:03 库
drwxr-xr-x@ 3 我的管理员 102 10 月 30 日23:10 MacOS
drwxr-xr-x@ 16 我的管理员 544 Oct 30 23:37 OtherFrameworks
-rw-r--r--@ 1 我的管理员 19 年 10 月 8 日 14:22 PkgInfo
drwxr-xr-x@ 56 我的管理员 1904 10 月 30 日 23:36 插件
drwxr-xr-x@ 52 我的管理员 1768 10 月 30 日 23:46 资源
drwxr-xr-x@ 17 我的管理员 578 10 月 30 日 23:46 SharedFrameworks
drwxr-xr-x@ 4 我的管理员 136 Oct 17 21:50 XPCServices
drwxr-xr-x@ 3 我的管理员 102 Oct 30 23:10 _CodeSignature
-rw-r--r--@ 1 我的管理员 523 Oct 30 23:10 version.plist

ls -l /Applications/Xcode.app/Contents/Developer  

总计 0
drwxr-xr-x@ 3 我的管理员 102 8 月 5 日 07:29 文档
drwxr-xr-x@ 7 我的管理员 238 12 月 20 日 21:09 库
drwxr-xr-x@ 7 我的管理员 238 Oct 30 23:46 Makefile
drwxr-xr-x@ 5 我的管理员 170 十月 30 23:28 平台
drwxr-xr-x@ 3 我的管理员 102 十月 10 01:37 工具链
drwxr-xr-x@ 22 我的管理员 748 十月 30 23:31 工具
drwxr- xr-x@ 7 我的管理员 238 Oct 30 23:46 usr
请帮忙。

4

6 回答 6

29

固定的!在终端:

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

说明:
阅读时man xcrun我注意到有 DEVELOPER_DIR 环境变量优先于 xcode-select。所以在这里我们将该变量设置为正确的路径。

于 2013-01-15T13:30:41.453 回答
17

运行这个来设置你的开发者文件夹:

sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
于 2014-01-31T07:58:10.847 回答
12

打开 Xcode > Preferences > Locations > 从下拉列表中选择您的 Xcode 版本并退出 Xcode ref

于 2018-12-24T10:13:51.760 回答
2

我已经尝试了所有可能的选项:

  • 重新安装 Xcode
  • 改变了各种路径
  • 重新安装开发者工具
  • 我什至重新安装了操作系统!

不过,从这里下载最新的 GIT 版本就可以了。

我认为这是升级操作系统的错误。我认为重新安装干净/格式也可以修复它(因为所有设置都被保留了)

请注意:重新启动当前终端窗口,这不是临时解决方案。

于 2015-11-25T14:36:10.063 回答
2

执行以下步骤

打开 Xcode

首选项->位置->命令行工具->选择Xcode版本

于 2019-06-12T11:45:00.963 回答
0

将以下行添加到 '~/.bashrc' 文件中:

export DEVELOPER_DIR=”/Applications/XCode.app/Contents/Developer”

运行source ~/.bashrc,然后重新启动终端。

于 2020-12-14T10:06:29.327 回答