I’m a big fan of not installing XCode on new Macs. I just don’t think it’s necessary, unless you’re genuinely building OS X or iOS applications.

Instead, I prefer to download the [Apple Command Line Tools] straight from Apple’s Developer Center, and install everything else I need to with Homebrew. Here’s how to do that.

First of all, download and install those command line tools. You’re going to need those first of all.

Next, install Homebrew. There are instructions on the site, but the quick version is:

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

Once homebrew install installed, you need to install another version of gcc (A compiler). There is a version of this that already comes with OS X, but it’s pretty old.

Enable the dupes homebrew package, and install an up-to-date version of GCC:

brew tap homebrew/dupes
brew install apple-gcc42

Theoretically, you now have the compilers, utilities, and tools you need to set up a range of packages on your Mac. One last problem that I’ve run into installing packages such as zsh and node, however, are programs that are run from the compilers to try and find XCode - and fail when they find it is not installed. The error looks something like this:

xcode-select: Error: No Xcode is selected. Use xcode-select -switch <path-to-xcode>, or see the xcode-select manpage (man xcode-select) for further information.

The solution for this is to tell these tools that Xcode is ‘installed’ in /usr/bin - where all the compilers are installed:

sudo xcode-select -switch /usr/bin

This stops xcode-select from erroring out and halting the compile process, by ensuring that it tries to find the compilers that it requires by looking in the directory where they are already installed.

Once all these steps are completed, you should have a full set of developer tools installed - all you need to compile almost all of the many Homebrew recipes that are available.


Note: The original instructions for setting up command-line tools and gcc-4.2 come from: http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion. The xcode-select fix comes from this issue report on the Homebrew repository