Catalina Install Xcode Command Line Tools

Programming

Command

All you need are the standalone Command Line Tools, which you can install by reading this guide. If the answer is “yes”, then you will need to download and install Xcode from the Apple App Store. Xcode is a Mac application built by Apple, and it cannot be installed with Homebrew.

  1. I don’t intend to install the large Xcode from the appstore. So I’ve tried to delete the existing installation of the command line tools with. Sudo rm -rf /Library/Developer. But the problem is still present. Many people suggest to go to the developer.apple.com page and to search manually for the Xcode command line tools.
  2. It started failing when I was doing npm install. The issue reported was regarding the xcode-select CLT. We usually avoid installing full xcode and install the CLT (Command Line Tools) using xcode-select -install command. Tried to run the command again but it did not work as CLT was already installed. I did struggle for sometime to fix the issue.
  3. Select “Install” to begin installation of XCode Command Line Tools on macOS Big Sur: If additional tools need to be installed accept the prompts give to proceed. Then wait for the downloading and installation of XCode Command Line Tools on macOS Big Sur to complete. Confirm if the installation was successful by running the following command.

Getting Rid of Xcode Command Line Tools

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.

Catalina Install Xcode Command Line Tools List

Uninstalling Xcode Command Line Tools

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.

  1. Remove the files consisting the command line tools.
  2. 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.

  1. Restart your mac and hold ⌘R to boot into macOS Recovery.
  2. Go through the language selection and select your preferred language.
  3. In the Recovery Tool, open Disk Utility
  4. Select your mac’s internal drive (usually named “Macintosh HD” if you haven’t renamed it) and then click mount.
  5. You probably need to select an administrative user and enter that user’s password to unlock the drive.
  6. Having mounted the internal drive, close the Disk Utility app.
  7. The Recovery Tool should appear again.
  8. This time click Utility option in the menu bar and then Terminal
  9. The Terminal app should open.
  10. Using the Terminal, locate your mounted internal drive in the /Volumes folder and list its files. Again, the name is likely “Macintosh HD”
  11. You should see a familiar macOS boot volume folder structure.
  12. Then go to the System/Library/Receipts folder
  13. Look for the command line tools receipts files.
  14. If they are there, remove them
  15. 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.

Catalina Install Xcode Command Line Tools Free

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.

Catalina Install Xcode Command Line Tools

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.

Catalina Install Xcode Command Line Tools

Can't Install Xcode Command Line Tools Catalina

  1. Open Xcode IDE
  2. In Xcode’s application menu, select the Preferences menu option.
  3. Activate the “Locations” tab
  4. 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).
  5. Open Terminal
  6. Enter the following command and ensure that the output points to a location from within Xcode.app’s bundle:
Catalina Install Xcode Command Line Tools

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.

2
4
exportCFLAGS='-I${xcode_path}/usr/include'
exportLDFLAGS='-L${xcode_path}/usr/lib'

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.

Catalina Install Xcode Command Line Tools Windows 10