安装 Xcode 命令行工具
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52513927/
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
Installing Xcode command line tools
提问by Nimesh Neema
I performed a fresh install of macOS Mojave 10.14. Immediately after that I installed Xcode Version 10.0 (10A255) from the Mac App Store.
我执行了 macOS Mojave 10.14 的全新安装。紧接着我从 Mac App Store 安装了 Xcode Version 10.0 (10A255)。
Now, I wish to install Homebrew which requires Xcode command line tools to be installed. My understanding is that installing Xcode also installs the command line tools. Or not?
现在,我希望安装 Homebrew,它需要安装 Xcode 命令行工具。我的理解是安装 Xcode 也会安装命令行工具。或不?
As per this answer, I checked if the command line tools are installed by running:
根据这个答案,我通过运行检查是否安装了命令行工具:
xcode-select -p
xcode-select -p
which printed the path for the Developer directory as follows:
它打印了 Developer 目录的路径,如下所示:
/Applications/Xcode.app/Contents/Developer
As suggested in the answer, I also verified the return value by running:
正如答案中所建议的,我还通过运行验证了返回值:
echo $?
echo $?
which retuned 0
.
哪个重新调整0
。
I also ran, gcc
and make
and bash was able to locate and execute them.
我也跑了,gcc
而且make
bash 能够找到并执行它们。
Thus far I am convinced that the Xcode command line tools are installed. Now when I execute:
到目前为止,我确信 Xcode 命令行工具已安装。现在当我执行:
xcode-select --install
xcode-select --install
I get this alert:
我收到此警报:
What's the probable reason for this disparity? Will this install Xcode command line tools twice? Or overwrite the existing installation?
这种差异的可能原因是什么?这会安装 Xcode 命令行工具两次吗?或者覆盖现有的安装?
As I understand, Xcode command line tools can be installed withoutinstalling Xcode. Also, from my previous experience, if the command line tools aren't installed separately from Xcode (by running xcode-select --install
), they are not detected by Homebrew, i.e. when running brew config
, the value for CLT:
is shown as N/A
.
据我了解,无需安装 Xcode即可安装 Xcode命令行工具。另外,根据我之前的经验,如果命令行工具没有与 Xcode 分开安装(通过运行xcode-select --install
),它们不会被 Homebrew 检测到,即运行时brew config
, 的值CLT:
显示为N/A
。
Here's the complete picture (pardon the pun):
这是完整的图片(请原谅双关语):
Although I am talking in context of macOS Mojave, the question remains the same with regard to previous versions of macOS.
虽然我是在 macOS Mojave 的上下文中讨论的,但对于以前版本的 macOS,问题仍然相同。
What is the advisable approach to take here?
什么是可取的方法在这里采取?
Note: After installing Xcode, I launched it, accepted license agreement and let it finish its run of installing additional tools (which is a one time activity).
注意:安装 Xcode 后,我启动它,接受许可协议并让它完成安装其他工具的运行(这是一次性活动)。
回答by Jyoti Prakash
Following worked for me, only command line tool can also me installed.
以下对我有用,只有命令行工具也可以安装。
After you updated to Mojave 10.14Go to https://developer.apple.com/download/more/search for "command line" then
更新到Mojave 10.14 后转到https://developer.apple.com/download/more/搜索“命令行”然后
Download "Command line tool for MacOS 10.14"
下载“ MacOS 10.14 命令行工具”
Once dmg is downloaded install the package.
下载 dmg 后,安装该软件包。