Xcode已安装但我无法使用xcode-select命令,“xcode-select: command not found”

4

我尝试从developer.apple.com和应用商店安装XCode 6.1.1,还尝试从developer.apple.com安装开发人员工具。

但无论哪种方式,都无法安装xcode-select

xcode-select --install
-bash: xcode-select: command not found

我确保它可以在我的PATH变量中看到/usr/bin

k$ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/System/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/Users/k/.rvm/bin:/Users/k/.rvm/bin

但事实证明,xcode-select不在bin文件夹中:

k$ ls /usr/bin/x*
/usr/bin/xar             /usr/bin/xgettext5.18.pl /usr/bin/xpath5.18
/usr/bin/xargs           /usr/bin/xip             /usr/bin/xslt-config
/usr/bin/xattr           /usr/bin/xjc             /usr/bin/xsltproc
/usr/bin/xattr-2.6       /usr/bin/xml2-config     /usr/bin/xsubpp
/usr/bin/xattr-2.7       /usr/bin/xml2man         /usr/bin/xsubpp5.16
/usr/bin/xcrun           /usr/bin/xmlcatalog      /usr/bin/xsubpp5.18
/usr/bin/xed             /usr/bin/xmllint         /usr/bin/xxd
/usr/bin/xgettext.pl     /usr/bin/xpath
/usr/bin/xgettext5.16.pl /usr/bin/xpath5.16

甚至根本就没有在我的系统上:
k$ sudo find / | grep xcode-select
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/share/man/man1/xcode-select.1
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/share/man/man1/xcode-select.1
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Users/k/.Trash/Xcode 00-40-10.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/share/man/man1/xcode-select.1
/Users/k/.Trash/Xcode 00-40-10.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/share/man/man1/xcode-select.1
/Users/k/.Trash/Xcode 21-31-08-775.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/share/man/man1/xcode-select.1
/Users/k/.Trash/Xcode 21-31-08-775.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/share/man/man1/xcode-select.1
/Users/k/.Trash/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/share/man/man1/xcode-select.1
/Users/k/.Trash/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/share/man/man1/xcode-select.1/usr/share/man/man1/xcode-select.1

我该怎么做?
其他XCode信息: 第一次打开Xcode时,当我点击“接受条款”时,它卡住了,所以我不得不强制退出。现在Xcode会打开,但如果我尝试进入“首选项”中的“位置”部分,它会卡住。这是我在第一次打开Xcode并进入“首选项”中的“位置”部分时从控制台获得的错误列表。 http://i.stack.imgur.com/YyMgR.png 感谢您的帮助!

我会进入你的“应用程序”文件夹,将“XCode”拖到垃圾桶中,清空垃圾桶,重新启动计算机,返回AppStore并再次下载它。 - Mark Setchell
尝试过了,但没有成功。还在Library中删除了Developer文件夹,但不幸的是仍然没有成功。 - Kristy Hughes
3个回答

5
我通过手动添加文件 /usr/bin/xcode-select 解决了这个问题,这个文件显然非常小。
$ echo -e '#!/bin/sh\nexec"$@"' > /usr/bin/xcode-select
$ sudo chmod +x /usr/bin/xcode-select

我得到了“/usr/bin/xcode-select: 操作不允许”的消息。 - Malwinder Singh
那么如果系统中根本没有 xcode-select ... 你从哪里得到它的? - Ky -

5

对我来说,已经接受的解决方案不起作用,所以我想分享这个内容,以防有人需要。在手动安装命令行工具后,这条命令就可以解决问题(xcode-select 在我的 /usr/bin/ 文件夹中):

sudo xcode-select --switch /

两个部分都对我有帮助——xcode-select 在 /usr/bin 中以及 --switch 命令。谢谢! - dhaag23

1

只需在终端上运行以下命令:

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

$ export DEVELOPER_DIR

当我遇到类似问题时,这篇文章对我很有帮助。谢谢。 - H S

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