Catalina Install Xcode Command Line Tools

Quickstart

  1. Catalina Install Xcode Command Line Tools
  2. Catalina Install Xcode Command Line Tools Download
  3. Can't Install Xcode Command Line Tools Catalina
  1. Install Xcode and the Xcode Command Line Tools
  2. Agree to Xcode license in Terminal: sudo xcodebuild -license
  3. Install MacPorts for your version of the Mac operating system:

With Xcode 4 and later, users need to accept the Xcode EULA by either launching Xcode or running: xcodebuild -license; Apple's Command Line Developer Tools, which can be installed on recent OS versions by running this command in the Terminal: xcode-select -install. Mac users with macOS Mojave and macOS Catalina, and new operating systems in place can now install Command Line Tools from the Xcode IDE without needing to install the entire Xcode package, or opening an Apple developers account.

Installing MacPorts

MacPorts version 2.7.1 is available in various formats for download and installation (note, if you are upgrading to a new major release of macOS, see the migration info page):

  • “pkg” installers for Big Sur, Catalina, and Mojave, for use with the macOS Installer. This is the simplest installation procedure that most users should follow after meeting the requirements listed below. Installers for legacy platforms High Sierra, Sierra, El Capitan, Yosemite, Mavericks, Mountain Lion, Lion, Snow Leopard, Leopard and Tiger are also available.
  • In source form as either a tar.bz2 package or a tar.gz one for manual compilation, if you intend to customize your installation in any way.
  • Git clone of the unpackaged sources, if you wish to follow MacPorts development.
  • The selfupdate target of the port(1) command, for users who already have MacPorts installed and wish to upgrade to a newer release.

Checksums for our packaged downloads are contained in the corresponding checksums file.

The public key to verify the detached GPG signatures can be found under the attachments section on jmr's wiki page. (Direct Link).

Please note that in order to install and run MacPorts on macOS, your system must have installations of the following components:

  1. Apple's Xcode Developer Tools (version 12.2 or later for Big Sur, 11.3 or later for Catalina, 10.0 or later for Mojave, 9.0 or later for High Sierra, 8.0 or later for Sierra, 7.0 or later for El Capitan, 6.1 or later for Yosemite, 5.0.1 or later for Mavericks, 4.4 or later for Mountain Lion, 4.1 or later for Lion, 3.2 or later for Snow Leopard, or 3.1 or later for Leopard), found at the Apple Developer site, on your Mac operating system installation CDs/DVD, or in the Mac App Store. Using the latest available version that will run on your OS is highly recommended, except for Snow Leopard where the last free version, 3.2.6, is recommended.

    With Xcode 4 and later, users need to accept the Xcode EULA by either launching Xcode or running:

  2. Apple's Command Line Developer Tools, which can be installed on recent OS versions by running this command in the Terminal:

    Older versions are found at the Apple Developer site, or they can be installed from within Xcode back to version 4. Users of Xcode 3 or earlier can install them by ensuring that the appropriate option(s) are selected at the time of Xcode's install ('UNIX Development', 'System Tools', 'Command Line Tools', or 'Command Line Support').

  3. (Optional) The X11 windowing environment, for ports that depend on the functionality it provides to run. You have multiple choices for an X11 server:
    • Install the xorg-server port from MacPorts (recommended).
    • The XQuartz Project provides a complete X11 release for macOS including server and client libraries and applications.
    • Apple's X11.app is provided by the “X11 User” package on older OS versions. It is always installed on Lion, and is an optional installation on your system CDs/DVD with previous OS versions.

macOS Package (.pkg) Installer

The easiest way to install MacPorts on a Mac is by downloading the pkg or dmg for Big Sur, Catalina, Mojave, High Sierra, Sierra, El Capitan, Yosemite, Mavericks, Mountain Lion, Lion, Snow Leopard, Leopard or Tiger and running the system's Installer by double-clicking on the pkg contained therein, following the on-screen instructions until completion.

This procedure will place a fully-functional and default MacPorts installation on your host system, ready for usage. If needed your shell configuration files will be adapted by the installer to include the necessary settings to run MacPorts and the programs it installs, but you may need to open a new shell for these changes to take effect.

The MacPorts “selfupdate” command will also be run for you by the installer to ensure you have our latest available release and the latest revisions to the “Portfiles” that contain the instructions employed in the building and installation of ports. After installation is done, it is recommended that you run this step manually on a regular basis to to keep your MacPorts system always current:

At this point you should be ready to enjoy MacPorts!

Type “man port” at the command line prompt and/or browse over to our Guide to find out more information about using MacPorts. Help is also available.

Source Installation

If on the other hand you decide to install MacPorts from source, there are still a couple of things you will need to do after downloading the tarball before you can start installing ports, namely compiling and installing MacPorts itself:

  1. cd” into the directory where you downloaded the package and run “tar xjvf MacPorts-2.7.1.tar.bz2” or “tar xzvf MacPorts-2.7.1.tar.gz”, depending on whether you downloaded the bz2 tarball or the gz one, respectively.
  2. Build and install the recently unpacked sources:
    • cd MacPorts-2.7.1
    • ./configure && make && sudo make install
    Optionally:
    • cd ../
    • rm -rf MacPorts-2.7.1*

These steps need to be perfomed from an administrator account, for which “sudo” will ask the password upon installation. This procedure will install a pristine MacPorts system and, if the optional steps are taken, remove the as of now unnecessary MacPorts-2.7.1 source directory and corresponding tarball.

To customize your installation you should read the output of “./configure --help | more” and pass the appropriate options for the settings you wish to tweak to the configuration script in the steps detailed above.

You will need to manually adapt your shell's environment to work with MacPorts and your chosen installation prefix (the value passed to configure's --prefix flag, defaulting to /opt/local):

  • Add ${prefix}/bin and ${prefix}/sbin to the start of your PATH environment variable so that MacPorts-installed programs take precedence over system-provided programs of the same name.
  • If a standard MANPATH environment variable already exists (that is, one that doesn't contain any empty components), add the ${prefix}/share/man path to it so that MacPorts-installed man pages are found by your shell.
  • For Tiger and earlier only, add an appropriate X11 DISPLAY environment variable to run X11-dependent programs, as Leopard takes care of this requirement on its own.

Lastly, you need to synchronize your installation with the MacPorts rsync server:

Upon completion MacPorts will be ready to install ports!

It is recommended to run the above command on a regular basis to keep your installation current. Type “man port” at the command line prompt and/or browse over to our Guide to find out more information about using MacPorts. Help is also available.

Git Sources

If you are developer or a user with a taste for the bleeding edge and wish for the latest changes and feature additions, you may acquire the MacPorts sources through git. See the Guide section on installing from git.

Purpose-specific branches are also available at the https://github.com/macports/macports-base/branches url.

Alternatively, if you'd simply like to view the git repository without checking it out, you can do so via the GitHub web interface.

Selfupdate

If you already have MacPorts installed and have no restrictions to use the rsync networking protocol (tcp port 873 by default), the easiest way to upgrade to our latest available release, 2.7.1, is by using the selfupdate target of the port(1) command. This will both update your ports tree (by performing a sync operation) and rebuild your current installation if it's outdated, preserving your customizations, if any.

Other Platforms

Running on platforms other than macOS is not the main focus of The MacPorts Project, so remaining cross-platform is not an actively-pursued development goal. Nevertheless, it is not an actively-discouraged goal either and as a result some experimental support does exist for other POSIX-compliant platforms such as *BSD and GNU/Linux.

The full list of requirements to run MacPorts on these other platforms is as follows (we assume you have the basics such as GCC and X11):

Catalina Install Xcode Command Line Tools

  • Tcl (8.4 or 8.5), with threads.
  • mtree for directory hierarchy.
  • rsync for syncing the ports.
  • cURL for downloading distfiles.
  • SQLite for the port registry.
  • GNUstep (Base), for Foundation (optional, can be disabled via configure args).
  • OpenSSL for signature verification, and optionally for checksums. libmd may be used instead for checksums.

Normally you must install from source or from an git checkout to run MacPorts on any of these platforms.

Help

Help on a wide variety of topics is also available in the project Guide and through our Trac portal should you run into any problems installing and/or using MacPorts. Of particular relevance are the installation & usage sections of the former and the FAQ section of the Wiki, where we keep track of questions frequently fielded on our mailing lists.

If any of these resources do not answer your questions or if you need any kind of extended support, there are many ways to contact us!

Programming

Catalina install xcode command line tools windows 10

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.

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.

  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.

Line

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 Download

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 free
  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.

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.

Can't Install Xcode Command Line Tools Catalina

Until next time.