How to uninstall Xcode IDE without completely removing the dev tools

I wanted to enable the developer libraries in Mac (RoR, Perl, gcc etc.) so I installed Xcode 3.2. I am only interested in these command-line tools and will not be using Xcode (or other GUI tools with Mac and iPhone developer bells and whistles that are part of the SDK) at all, as I generally like to use a text editor and the command line.

How do I remove just those IDE tools while still keeping my programming environment intact? I'd rather reclaim the disk space.


Solution 1:

As of recent releases of Xcode 4 you can now get the command-line tools as a separate download and installer - it's a much smaller download too: http://developer.apple.com/downloads.

You'll want to uninstall an existing Xcode install with the command:

$ sudo /Developer/Library/uninstall-devtools --mode=all

before installing the command-line only tools.

Solution 2:

Updating the answer for users looking to do the same in 2020.

(Tested on macOS Catalina 10.15.2)

Method:

  1. Uninstall the Xcode app - you can use storage management for this.
  2. Install the command line tools via the command xcode-select install
  3. Now try g++ -v, if you get an xcrun error which says that you need to install xcode command line tools using xcode-select install (which you just did), type in the xcode-select install again. If you get 'use "Software Update" to install update' error but you don't have any software updates to install in softwareupdate --list, try:
    sudo xcode-select --reset