如何使用当前的Xcode/Mac OS X v10.8 (Mountain Lion)或更高版本安装命令行构建工具?
与Xcode不同,它没有安装程序,只是一个包。
看起来所有的命令行工具都在包中,在Contents/Developer下面,但是没有设置适当的环境变量来使用它们。
是否有一个脚本,我可以运行,将设置我的环境,以支持从命令行构建?
如何使用当前的Xcode/Mac OS X v10.8 (Mountain Lion)或更高版本安装命令行构建工具?
与Xcode不同,它没有安装程序,只是一个包。
看起来所有的命令行工具都在包中,在Contents/Developer下面,但是没有设置适当的环境变量来使用它们。
是否有一个脚本,我可以运行,将设置我的环境,以支持从命令行构建?
当前回答
通过将我的Mac更新到最新的Mac OS(即Big Sur),一切都分解为重复要求安装Xcode-select。
这可能看起来很奇怪,但我通过重新安装并更新到最新的Xcode解决了这个问题。
这只是我解决问题的经验。
其他回答
尝试进入Xcode > Preferences…>下载并单击命令行工具旁边有向下箭头的圆形按钮。
至于大sur..
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
感谢自制啤酒维护者把这有用的消息在酿造医生
您可以在bash中自动安装命令行工具。在自动化开发人员入职设置过程时,我需要这样做。
xcode-select --install && sleep 1
osascript -e 'tell application "System Events"' -e 'tell process "Install Command Line Developer Tools"' -e 'keystroke return' -e 'click button "Agree" of window "License Agreement"' -e 'end tell' -e 'end tell'
Xcode Command Line Tools can be installed as a side effect of running git --version in Terminal without Git installed. You will be prompted to install the tools as a requirement for running Git. Apple ships a binary of git with the Command Line tools. This is confirmed on the Git for Mac Download page. This seems like a valid option considering that Homebrew requires the Command Line tools to install Git as well according to another SO post. Otherwise, the previous answers are the most direct methods of install the tools.
除了从Apple安装命令行工具的“官方”版本,你也可以从这里安装Kenneth的版本:
https://github.com/kennethreitz/osx-gcc-installer
如果你所追求的只是命令行工具,它甚至不需要XCode。