Additional Downloads
I had a lot of trouble installing ruby 2.0.0 on mountain lion. Tried various things recommended on different forums and blogs, but the one that was easiest and worked best for me was the one written by Christopher Kaukis on the. Apr 28, 2013 Normally the CLI tools for XCode are available in XCode's downloads preferences. Open XCode and press Command-, to get to the preferences (or choose them from the XCode application menu), then go to the downloads section and in the Components tab you should see the command line tools listed as an option to install.
Get the latest beta and older versions of Xcode. To view downloads, simply sign in with your Apple ID. Apple Developer Program membership is not required.
Beta Versions of Xcode
Command Line Tools & Older Versions of Xcode
Command Line Tools & Older Versions of Xcode
Videos
See the latest advances in Xcode presented at WWDC and other events.
Help and Support
Get step-by-step guidance on how to use Xcode to build, test, and submit apps to the App Store.
Xcode Help Guide
Xcode Support Page
Xcode Support Page
API Reference and Sample Code
Browse the latest documentation including API reference, articles, and sample code.
Discussion Forums
Ask questions and discuss development topics with Apple engineers and other developers.
Install Xcode command line tools on 10.7.x - 10.10.x. Tested on 10.7.5, 10.8.5, 10.9.5 and 10.10.2.
gistfile1.sh
#!/bin/bash |
# Installing the Xcode command line tools on 10.7.x or higher |
osx_vers=$(sw_vers -productVersion | awk -F '.''{print $2}') |
cmd_line_tools_temp_file='/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress' |
# Installing the latest Xcode command line tools on 10.9.x or higher |
if [[ '$osx_vers'-ge 9 ]];then |
# Create the placeholder file which is checked by the softwareupdate tool |
# before allowing the installation of the Xcode command line tools. |
touch '$cmd_line_tools_temp_file' |
# Find the last listed update in the Software Update feed with 'Command Line Tools' in the name |
cmd_line_tools=$(softwareupdate -l | awk '/* Command Line Tools/ { $1=$1;print }'| tail -1 | sed 's/^[[ t]]*//;s/[[ t]]*$//;s/*//'| cut -c 2-) |
#Install the command line tools |
softwareupdate -i '$cmd_line_tools' -v |
# Remove the temp file |
if [[ -f'$cmd_line_tools_temp_file' ]];then |
rm '$cmd_line_tools_temp_file' |
fi |
fi |
# Installing the latest Xcode command line tools on 10.7.x and 10.8.x |
# on 10.7/10.8, instead of using the software update feed, the command line tools are downloaded |
# instead from public download URLs, which can be found in the dvtdownloadableindex: |
# https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex |
if [[ '$osx_vers'-eq 7 ]] || [[ '$osx_vers'-eq 8 ]];then |
if [[ '$osx_vers'-eq 7 ]];then |
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_lion_april_2013.dmg |
fi |
if [[ '$osx_vers'-eq 8 ]];then |
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_osx_mountain_lion_april_2014.dmg |
fi |
TOOLS=cltools.dmg |
curl '$DMGURL' -o '$TOOLS' |
TMPMOUNT=`/usr/bin/mktemp -d /tmp/clitools.XXXX` |
hdiutil attach '$TOOLS' -mountpoint '$TMPMOUNT' -nobrowse |
# The '-allowUntrusted' flag has been added to the installer |
# command to accomodate for now-expired certificates used |
# to sign the downloaded command line tools. |
installer -allowUntrusted -pkg '$(find $TMPMOUNT -name '*.mpkg')' -target / |
hdiutil detach '$TMPMOUNT' |
rm -rf '$TMPMOUNT' |
rm '$TOOLS' |
fi |
exit 0 |
commented Jul 26, 2016
This is awesome. The only thing I could recommend is change installer -allowUntrusted -pkg... to sudo installer -allowUntrusted -pkg... and it works great. And if you want to detect if Xcode CL Tools is installed then just run pkgutil --pkgs | grep com.apple | grep CL | grep Tools (I have tested this on 10.7.x, 10.8.x, 10.9.x, 10.10.x, and 10.11.x). |
commented Nov 16, 2016
Fantastically useful script. I noticed a problem running the script on MacOS Sierra unfortunately. Softwareupdate may have changed. softwareupdate: invalid option -- v |
commented Nov 23, 2016
Command Line Tools For Xcode 9.2
We found dropping the -v from the script makes it work for our Sierra deployments now. |
commented Aug 4, 2018
Thanks so much for this! Is there an xcode-select --switch required afterwards? |
Xcode Command Line Tools 10.14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment