Here is a script that will automate the install process for you:
# Try the AppleScript automation method rather than relying on manual .xip / .dmg download & mirroring
# Note: Apple broke automated Xcode installer downloads. Now requires manual Apple ID sign-in.
# Source: https://web.archive.org/web/20211210020829/https://techviewleo.com/install-xcode-command-line-tools-macos/
tell application "System Events"
tell process "Install Command Line Developer Tools"
click button "Agree" of window "License Agreement"
Older Solution (pre-2021)
You can download the XCode
4.x CLTools packages from their official download site via direct links.
Here is a script that will automate the install process for you 1.
To find updated links for the tools, you can use this command:
curl -Ls https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex | plutil -convert json -o - - | python -mjson.tool | less
 Please don't abuse/overload their servers
EDIT: (2021-2022) This URL appears to have an invalid SSL certificate. The
curl command (if run in verbose
-v mode) shows that the
https certificate is invalid:
* Server certificate:
* subject: C=US; ST=Massachusetts; L=Cambridge; O=Akamai Technologies, Inc.; CN=*.test.edgekey.net
* start date: Sep 24 00:00:00 2021 GMT
* expire date: Sep 23 23:59:59 2022 GMT
* subjectAltName does not match devimages.apple.com.edgekey.net
* SSL: no alternative certificate subject name matches target host name 'devimages.apple.com.edgekey.net'
The old URL now returns an SSL error. The
curl command must now use the
-k / --insecure flag to work around the SSL certificate validation issue.
curl --insecure -Ls https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex | plutil -convert json -o - - | python -mjson.tool | less
- This URL now appears to have broken SSL certificates, and the latest version available is
Xcode.CLTools.10.8 version 2014.4 (
curl command above now has the
-k flag added to work around this certificate validation issue. Be aware that the
-k / --insecure command line option flag will bypass SSL certificate security checks. This is insecure and there is no way to verify using a PKI + CA chain of trust that this domain is trustworthy and still owned by Apple. It's recommended to use the alternative
xcode-select --install +
osascript solution above.