Post-XCode 4.3 (when XCode was moved to the Mac App Store), the Command Line Tools are now a separate download (either from within XCode or from ADC). This also means that you can install the Command Line Tools without needing all 4.4GB of XCode thanks largely to Kenneth Reitz’s work on OSX-GCC-Installer. Pretty sweet, and designed to work with Homebrew.
MacPorts has served me well over the past few years without much fuss, but it’s apparently not done well for people upgrading XCode (see the Problem Hotlist and sample Stack Overflow answer if you have that problem). Now this is all fine and good with XCode, but what if you want to just use the Command Line Tools and skip XCode entirely?
Well, I’m glad you asked. Mostly it involves running the following:
xcode-select --switch /usr/bin
This makes xcrun point to the correct location when running binaries, however, if MacPorts is giving you guff about not having XCode installed this is what I did:
# cd /usr/bin # mv xcodebuild xcodebuild.orig # touch xcodebuild # chmod a+x xcodebuild
#!/bin/bash if [[ $1 == '-version' ]]; then echo "Xcode 4.4" echo "Build version 4F250" else # Pass Through /usr/bin/xcodebuild.orig $@ fi
MacPorts seems to use
xcrun xcodebuild -version to check the XCode version, so I just get it to lie when it asks.
Now, this is quite ugly, and the proper way to do things would probably be to either actually install XCode or perhaps, finally make the switch to Homebrew, but I thought I’d post this in case it comes in handy for people…