MacOS – Is it possible to download Apple’s Command Line Tools for Xcode from the command line

command linemacosterminalxcode


My job gives me temporary MacBook Pros for travel purposes. I get them with a fresh OS install before I leave, and when I return, they blank the hard drive. The trips usually require some sort of development work, which means I'd prefer to install my entire development stack on the machine, but doing so every time would be tedious and a waste of time. I'd like to write a script that does all of the installation for me.


The big issue I've run into is having to download the Xcode command line tools. For the time being, I can stash the DMG in my Dropbox or some sort of privately accessible cloud storage. I was wondering, however: is there a way to download these tools from Apple in a scriptable fashion? The main obstacle seems to be logging into Apple's Developer site. If I could download the DMG from Apple in a way that only required me to type in my ID and password from the command line, that would be great (or even better, download it without a password).

From searching around, it seems like there may exist URLs for the command line tools that may allow me to download them from the command line. (see, for instance:

Best Answer

Apple now includes the xcode-select binary in OS X itself, so you have a one line solution that presents a graphical authorization window and then downloads and installs the current version of the tools.

xcode-select --install