如何确定我是否安装了 Xcode 命令行工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21272479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I find out if I have Xcode commandline tools installed?
提问by P i
I need to use gdb.
我需要使用gdb。
ps-MacBook-Air:AcoustoExport pi$ gdb
-bash: gdb: command not found
ps-MacBook-Air:AcoustoExport pi$ sudo find / -iname "*gdb*"
Password:
/usr/local/share/gdb
/usr/local/Cellar/isl/0.12.1/share/gdb
:
and:
和:
ps-MacBook-Air:AcoustoExport pi$ ls -la /usr/local/share/gdb
lrwxr-xr-x 1 pi admin 30 14 Jan 22:01 gdb -> ../Cellar/isl/0.12.1/share/gdb
Not quite sure what to make this, clearly it is something installed by homebrew. I don't know why it's there, I don't know whether I could use it instead. It isn't in the search path.
不太确定要做什么,显然这是自制软件安装的东西。我不知道它为什么在那里,我不知道我是否可以用它代替。它不在搜索路径中。
So I figure I need Xcode commandline tools.
所以我想我需要 Xcode 命令行工具。
Xcode is not currently available from the Software Update server
^ my current problem exactly. Comment on that question says "you can get this error if you have them already"
^ 正是我目前的问题。对该问题的评论说“如果你已经有了它们,你就会得到这个错误”
But how do I check whether I have them already?
但是我如何检查我是否已经拥有它们?
回答by crujzo
/usr/bin/xcodebuild -version
will give you the xcode version, run it via Terminal command
会给你 xcode 版本,通过终端命令运行它
回答by Siavash Alp
First of all, be sure that you have downloaded it or not. Open up your terminal application, and enter $ gcc
if you have not installed it you will get an alert. You can verify that you have installed it by
首先,请确保您是否已下载它。打开你的终端应用程序,$ gcc
如果你还没有安装它,你会得到一个警告。您可以通过以下方式验证您是否已安装它
$ xcode-select -p
/Library/Developer/CommandLineTools
And to be sure then enter $ gcc --version
并确定然后输入 $ gcc --version
You can read more about the process here: Xcode command line tools for Mavericks
您可以在此处阅读有关此过程的更多信息:Mavericks 的 Xcode 命令行工具
回答by Kiran jadhav
if you want to know the install version of Xcode as well as Swift language current version:
如果您想知道 Xcode 的安装版本以及 Swift 语言的当前版本:
Use below simple command by using Terminal:
使用终端使用以下简单命令:
1. To get install Xcode Version
1.获取安装Xcode版本
xcodebuild -version
2. To get install Swift language Version
2. 安装 Swift 语言版本
swift --version
回答by AlexG
I was able to find my version of Xcode on maxOS Sierra using this command:
我能够使用以下命令在 maxOS Sierra 上找到我的 Xcode 版本:
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
as per this answer.
根据这个答案。
回答by P i
Thanks to the folks on Freenode's #macdev, here is some information:
感谢 Freenode 的 #macdev 上的人们,这里有一些信息:
In the old days before Xcode was on the app-store, it included commandline tools.
在 Xcode 出现在应用商店之前的过去,它包含命令行工具。
Now you get it from the store, and with this new mechanism it can't install extra things outside of the Xcode.app, so you have to manually do it yourself, by:
现在您可以从商店获取它,并且通过这种新机制,它无法在 Xcode.app 之外安装额外的东西,因此您必须自己手动完成,通过以下方式:
xcode-select --install
On Xcode 4.x you can check to see if they are installed from within the Xcode UI:
在 Xcode 4.x 上,您可以检查它们是否是从 Xcode UI 中安装的:
On Xcode 5.x it is now here:
在 Xcode 5.x 上,它现在在这里:
My problem of finding gcc/gdb is that they have been superseded by clang/lldb: GDB missing in OS X v10.9 (Mavericks)
我找到 gcc/gdb 的问题是它们已被 clang/lldb 取代:OS X v10.9 (Mavericks) 中缺少 GDB
Also note that Xcode contains compiler and debugger, so one of the things installing commandline tools will do is symlink or modify $PATH. It also downloads certain things like git.
另请注意,Xcode 包含编译器和调试器,因此安装命令行工具要做的一件事是符号链接或修改 $PATH。它还下载某些东西,比如 git。
回答by SylvesterAbreuLoreto
If for some reason xcode is not installed under
如果由于某种原因 xcode 没有安装在
/usr/bin/xcodebuild
/usr/bin/xcodebuild
execute the following command
执行以下命令
which xcodebuild
which xcodebuild
and if it is installed, you'll be prompted with it's location.
如果已安装,系统会提示您它的位置。