如何解决"Error: No developer directory found at /Developer"错误?

101
我刚升级到 XCode 4.3.1。 我使用一个脚本来构建(然后通过 Testflight 部署)我的应用程序。 但是现在出现了这个错误:
错误:/Developer 中找不到开发人员目录。运行 /usr/bin/xcode-select 更新开发人员目录路径。
我的机器上没有 /Developer 目录:我该如何解决?
4个回答

245

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


3
如果那样做不起作用怎么办?我按照你说的做了,没有出现错误,然后运行“xcodebuild -version”,但是出现了错误:“Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path.” - Henning
1
由于大约在Xcode 4.2版本之后,苹果开始将其作为应用程序通过App Store进行下载分发。因此,所有的工具都安装在Applications/Xcode.app包中。 - Sudhir Jonathan
3
我不得不创建一个软链接,将/Developer指向/Applications/Xcode.app/Contents/Developer/。那是我找到的唯一解决方案。 - Henning
新路径似乎是 /Library/Developer:https://dev59.com/questions/Qmcs5IYBdhLWcg3wh0b7 - AndreyM
这个答案对我很有帮助,因为当我尝试运行cordova build时,我遇到了错误。我是在按照cordova ios平台指南(http://cordova.apache.org/docs/en/3.3.0/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide)进行操作时遇到的。其他人也在尝试按照这些指南进行操作时可能会遇到同样的问题。 - Daniel Dropik
显示剩余3条评论

5
您可以选择使用以下方法...
sudo ln -s /Applications/Xcode.app/Contents/Developer /Developer

6
这是试图掩盖问题而非解决问题的尝试。如果那样做,所有的工具仍然会在错误的地方寻找答案。 - Jim
即使执行了这个命令,我仍然会收到这个错误信息:xcode-select: Error: Path "/Applications/Xcode.app/Contents/Developer" is not a directory. 即使执行了这个命令,也没有Developer目录。 - abhishek

3
你们所回答的一切都是正确的。但那些遇到以下错误的人可能还缺少一步操作:
错误:
  "xcode-select: Error: Path "/Applications/Xcode.app/Contents/Developer" is not a directory."

缺少步骤:

Double click your xcode 432.dmg. Now don't double click the xcode.app to use it. Instead copy it /Applications folder and then open it from there to install xcode.

现在使用终端命令。
 sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

就是这样,您的错误不会再出现了,并且 Filemerge 现在可以正常工作。


很好,应该注意不将Xcode放入应用程序可能会导致这个问题。 - James

2

这对我有帮助:

通常出现此错误的原因是您安装了更新版本的Xcode。命令行工具尚未初始化。

要解决此问题:转到Xcode首选项>位置(选项卡)>底部选项为命令行工具。请为工具选择Xcode版本。

示例(针对Xcode 8.3.3):转到Xcode首选项>位置(选项卡)>底部选项为命令行工具。选择Xcode 8.3.3(7D1014)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接