Have you ever uninstalled Xcode Command Line Tools only to have it comes back again when Xcode gets updated or there’s a macOS update? You might have a need for the command line tools at that time but don’t need it any longer — however it seems to find a way to get back into your system.
I experienced this not too long ago. I installed Xcode’s command line tools because I needed an older version of Xcode for use with NVidia’s toolkit. Then when I no longer have the need, I’ve uninstalled it as per Apple’s directions. But strangely during the next macOS update cycle — which also updated Xcode in roughly the same time frame — I was prompted to update the command line tools as well. What’s worse, there’s no way to opt out and I ended up installing the command line tools only to un-install it again. What an annoyance and waste of bandwidth.
Fortunately after much, much googling, I’ve discovered a way to permanently uninstall this command line tools. I’ve also find a way to leverage the Xcode IDE for use by command line applications as well. Interested? Read on.
Uninstalling Xcode Command Line Tools
To remove Xcode Command Line Tools (which is, by the way, different than the full Xcode IDE), you will need to go through two steps.
- Remove the files consisting the command line tools.
- Remove the receipts to prevent it from coming back again.
The first step is easy enough. It’s the second step that’s rather tricky because these receipt files are located in a read-only zone guarded by System Integrity Protection (SIP).
Removing Xcode Command Line Tools
As per Apple’s document TN2339, removing the command line tools is as simple as deleting a folder.
However in my personal experience, the command line tools would just get installed again the next time it gets updated. Thus you will need to follow the next step to fully remove the command-line tools.
Removing Receipt Files
Another set of files that you would need to remove are the receipt files of Xcode command line tools. These files starts with the name
com.apple.pkg.CLTools* and resides in the
/System/Library/Receipts/ folder. However since its location is inside one of SIP’s protected folders, removing them is quite involved.
What you need to do is to boot into macOS Recovery and then remove those receipt files from there. There’s really no need to disable SIP and put your system at risk just to remove these few files. Booting from the Recovery OS also means that no other applications are running — which further reduce the risk of any malware modifying your crucial system files.
Follow these steps to remove those pesky command line tools receipt files.
- Restart your mac and hold ⌘R to boot into macOS Recovery.
- Go through the language selection and select your preferred language.
- In the Recovery Tool, open Disk Utility
- Select your mac’s internal drive (usually named “Macintosh HD” if you haven’t renamed it) and then click mount.
- You probably need to select an administrative user and enter that user’s password to unlock the drive.
- Having mounted the internal drive, close the Disk Utility app.
- The Recovery Tool should appear again.
- This time click Utility option in the menu bar and then Terminal
- The Terminal app should open.
- Using the Terminal, locate your mounted internal drive in the /Volumes folder and list its files. Again, the name is likely “Macintosh HD”
- You should see a familiar macOS boot volume folder structure.
- Then go to the System/Library/Receipts folder
- Look for the command line tools receipts files.
- If they are there, remove them
- And that’s it. The command line tools shouldn’t return unless you explicitly downloaded and install them again.
Using the Full Xcode as Command-Line Tools
Really, the command line tools are meant for those who doesn’t need the full Xcode IDE. Maybe they need it just for compiling open-source packages. Perhaps they only do cross-platform Unix development and uses Emacs, VIM, or some other text editors to write code. For those people, the full Xcode is a monstrosity: gigabytes containing IDE and simulators for three operating systems (iOS, tvOS, watchOS) that they are not going to write software for.
But if you really use Xcode to develop Apple-specific software, then the reverse is true: the command-line tools duplicates of what the full Xcode IDE already provide and hence would waste precious space on your startup volume. However, some open-source package’s build systems seems to require the command line tools. Is there a way to make them use the same compilers that Xcode IDE provide?
Yes there is. Read on.
The first step of business is to configure Xcode as the default compiler for the system. This is even more important if you have more than one copy of Xcode installed (the other one would likely be a beta of a future version of Xcode). Follow these steps to configure Xcode in the command line.
- Open Xcode IDE
- In Xcode’s application menu, select the Preferences menu option.
- Activate the “Locations” tab
- In the “Command Line Tools” section, select the current version of Xcode as default (you might be asked to enter your password or restart iTunes if you haven’t done this before).
- Open Terminal
- Enter the following command and ensure that the output points to a location from within Xcode.app’s bundle:
Now that you have setuo Xcode as the default compiler, you might want to setup a few environment variables to let open-source tools know about it. Edit your terminal session’s startup script – usually ~/.bash_profile and add these environment settings in.
Those variables would sets the header files needed to build C and C++ applications. Furthermore it also lets linkers know where to find static libraries for these languages.
And that’s just about it. You’ve just saved about 200 megabytes of space on your startup volume. Space that hopefully you can find better use.
Until next time.
3 thoughts on “Getting Rid of Xcode Command Line Tools”
Does not work. No receipts folder to be found in Monterey.
Hi Sasmito and thanks for your article. I’m running the latest version of Catalina (10.15.20 and want to get of the CLTools update warning, even after removing the command line tools subdir in /Developer.
I noticed the cCLTools pkg files were stored in /library/apple/system/library/receipts. After starting in maintenance mode, I was unable to delete those files unfortunately. The files simply were not visible in maintenance mode. Do you have any other ideas on how to delete them? Any help would be much appreciated!
Try looking at the boot volume (as opposed to Catalina’s data volume) in “/System/Library/Receipts” from the recovery OS. Google for “Catalina firmlinks” to find out more on this.
You must log in to post a comment.