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: https://stackoverflow.com/questions/9329243/xcode-4-4-command-line-tools)

  • 2
    Do you have XCode on the machine, but not the command line developer tools? I know if XCode is installed you can do xcodebuild -license; xcode-select --install to do an unattended install of the command line developer tools.
    – Ian C.
    Dec 22, 2013 at 22:45
  • Not usually. Typically, I'm given a machine with a fresh, vanilla install of OS X for security reasons. This situation could apply to migrating a setup to a new machine also, which is another reason I'm interested. After digging around the source code of the Developer Tools web site, I was able to find a URL I could use to download XCode via curl. That said, I'm not sure Apple wants the actual URL publicized, and they seem to go to considerable lengths to obfuscate the URL. Dec 24, 2013 at 5:10

2 Answers 2


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
  • Ah yes - but then they nobble it ... `xcode-select: error: no developer tools were found, and no install could be requested (perhaps no UI is present), please install manually from 'developer.apple.com' ... Chicken / Egg - which came first ...
    – Mr R
    Mar 19, 2021 at 5:54

Install wget and if you are running osx 10.8.5 usable keychain scripting for lion:


Pass your developer username and password to wget via "usable keychain scripting".

  • As you note, wget isn't installed by default, which makes it undesirable for bootstrapping a development setup. You can do something similar with curl with the -u option, which is installed by default (albeit an old version). I'd like to put the XCode download into a script under version control, so including even a user name is something I'd rather avoid, but I may have to live with. Dec 24, 2013 at 5:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .