Command Line Tools For Catalina

Programming

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.

MacOS Catalina Before we get right to how to install command line tools on macOS, let us look at what macOS Catalina is all about. Apple just made available a major release of its macOS codenamed macOS Catalina (version 10.15). MacOS Catalina is the sixteenth release of Apple’s desktop operating system for Macintosh computers. Command Line Tools on macOS macOS only 'I would like to use Beyond Compare with my Version Control System.' Or 'I tried to use the Beyond Compare menu to Install Command Line Tools but it failed.'

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.

  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.

Command Line Tools For Catalina
  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.

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.

  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:

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.

Command Line Tools For Catalina Free

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.


Xcode is the tool developers use to build apps for the Apple ecosystem – MacOS, iOS, and all things Apple.

This guide will walk you through how to successfully install Xcode onto your Mac, from start to finish.

Here are some handy tips to know before you get started:

  • Xcode only runs on a mac. If you are on a PC, sadly you won't be able to use Xcode.
  • You'll need a good, stable internet connection. The latest version is around 8 gigabytes in size.
  • Be sure to have at least 30 gigabytes of free space on your computer. The latest .xip file (v11.4.1 at the time of writing) is ~8 gigabytes zipped. When you unzip it, that's another 17 gigabytes. Then you'll need the command line tool, which is yet another 1.5 gigabytes.

Here's an overview of the steps to install Xcode

  1. Download Xcode
  2. Install the command line tool
  3. Open the new version
  4. Delete files

Note that I have listed some Terminal commands in the steps below. These commands can be typed into your present working directory. This means that you don't need to navigate to any particular folder.

If you really want to, you can first type cd before typing the commands in the below steps. This will return you back to the home folder.

Step #1: Download Xcode

There are two ways to do this. For the latest version and a theoretically 'easy' installation, you can use the App Store. I don't recommend this option.

I prefer to use the developer site. This comes with the bonus option of being able to download any version you'd like.

Option #1: Download via the App Store for the latest version (not my preferred option)

In theory, this should be a seamless and pain-free process. But if the installation fails for any reason on the last step, it is very hard to troubleshoot.

Command line tools for xcode catalina

There are a few reasons for failure, and no easy way to know which is the underlying cause. If you do encounter a failure, you will need to re-download the entire file again each time you try to fix the failure. As the latest version is 8 gigabytes, I didn't much enjoy this approach.

But if you're feeling brave, here are the steps:

  • Open the App Store on your mac
  • Sign in
  • Search for Xcode
  • Click install or update

Option 2: Download via the Developer site for a specific version (my preferred option)

  1. Head to the 'more' section of the Apple developer website
  2. Sign in with your iTunes account id
  3. Type in the version that you'd like, and download the Xcode_x_x_x.xip file. Keep in mind that Xcode 11.4.1 is 8 gigabytes, so this will take awhile depending on your internet connection.
  4. Once the file is downloaded, click on .xip to extract it. Your laptop will extract it to the same folder you downloaded it to. This extraction process is automatic. You don't need to do anything more after you click on the .xip file. This step will take a few minutes.
  5. [Optional] Once extracted, rename the application to “Xcode11.x.x” if you are using multiple versions.
  6. Drag application to the Applications folder
  7. [Optional] Set the new Xcode version as the default. Open Terminal and type sudo xcode-select -switch /Applications/Xcodex.x.x.app . Replace x.x.x with the version number. For example: Xcode11.4.1.app. You will need to enter in your computer admin password. I'm pretty sure this will update the default Xcode version for all users on your computer, so best to check with other users first

Step #2: Install the command line tool (CLT)

If you have multiple users on your computer, you will need to update the CLT for each user.

Download .dmg

To update the CLT, go to app developer website and download the command line tool .dmg.

If you have never installed Xcode before, you may be able to update with your Terminal by typing in xcode-select --install instead of visiting the developer website.

But if you have an existing version of Xcode installed on your machine, you'll probably see this error:

This means you'll need to go to the developer website instead.

Java Command Line Tools Catalina

Installing the CLT

When the .dmg has finished downloaded, double click the file to open it. This will open a little window that looks like this:

Double click the box and follow the prompts to install the CLT. It will take a few minutes to complete.

It may ask you at the end of the installation whether you want to move this to the trash bin. When it does this, it's talking about moving the .dmg file to the trash bin. Since you should no longer need this file. I always say yes to this.

Command Line Tools For Xcode Catalina

Step #3: Open Xcode

Open the Applications folder and open the new version of Xcode. If you renamed Xcode, make sure you open the correct application

Xcode may prompt you to install additional components. Click install. This will take a few minutes.

While it's installing, check that your default Xcode version is the one you just downloaded:

  • Open Terminal
  • Type brew config
  • You should see “CLT” and “Xcode” versions, as well as everything else. This should reflect the version that you have just downloaded. In my case, I downloaded Xcode 11.4.1.

Once the components are installed, Xcode will launch. You should be able to pick up your old projects and continue where you left off seamlessly*.

*Note that if you use any proxy tools, such as Charles, you will need to re-install those certificates in your simulator again.

If you encounter any errors while trying to build or run a project, check which device you are trying to launch. The new version may not remember the device you were using before. If so, click on the device and choose 'Add additional simulators' from the drop down menu to add the device you want.

Step #4. Delete the files

If you don't need the older versions of Xcode on your computer, you can uninstall them and get some hard drive space back.

You can also delete the .xip file of the version you just downloaded, as well as the CLT.dmg file.

That's everything. I hope this has helped you successfully install Xcode. Have fun with it!