How to Install Xcode Command Line Tools Package on Mac


If you prefer to code Mac apps using the command line, you need the Xcode Command Line Tools package. It contains compilers, debuggers, and other development tools and utilities accessible through Terminal without the entire Xcode integrated development environment.

If Xcode is already installed on your Mac, you don’t need this useful Unix toolkit. If not, this step-by-step tutorial will show you how to download, install and use the Xcode Command Line Tools package directly via the web or using the “xcode-select” install command in Terminal.

Xcode Command Line Tools is a self-contained package for software developers who wish to build Mac apps using UNIX-style commands.

It’s bundled with Apple’s Xcode integrated development environment, but a self-contained version is available to download separately from Xcode.

The Command Line Tools folder in macOS Finder

The Xcode Command Line Tools package consists of the software development kit (SDK) frameworks and headers, along with a myriad of tools such as Apple’s LLVM compiler and linker, the Make command, and other handy Terminal commands for command-line development. There are 112 Terminal commands included in Xcode Command Tools (as of v14.2).

Terminal, if you didn’t know, gives you access to the world of UNIX commands on your Mac. So, check out our comprehensive cheat sheet of Mac terminal commands to make the most from Terminal. It provides a great reference for all the essential commands you should know.

You can download and install Xcode Command Line Tools in two ways. You can either directly download it through the Apple Developer portal or manually install it using a Terminal command. We’ll cover both of these methods below.

Method 1: Get Xcode Command Line Tools From the Web

To manually download the Xcode Command Line Tools package, follow these steps:

  1. Go to and log in with your Apple ID.
  2. Type “command line tools” in the search field and hit Enter.
    Downloading Apple's Xcode Command Line Tools using Safari

  3. Click View Details below the entry you want and hit the listed DMG file to download it.
  4. Next, double-click the file in your Downloads folder to mount the disk image as a virtual disk.
    The Xcode Command Line Tools disk image selected in the Finder

  5. Next, open the file Command Line Tools.pkg from the mounted volume to launch the installer.
    The Xcode Command Line Tools installer package in macOS Finder

At this point, you can follow the on-screen instructions to finish the installation process.

Method 2: Use Terminal to Install Xcode Command Line Tools

Alternatively, you can always use the Terminal app on your Mac to download and install the Xcode Command Line Tools package:

  1. Launch Terminal on your Mac using Spotlight search (Cmd + Space).
  2. Type in the following command.
    xcode-select --install
  3. You’ll get a pop-up prompting you to install command line developer tools. Choose Install to continue.
    macOS Terminal prompt offering to download Xcode Command Line Tools

  4. You can verify your Xcode Command Line Tools installation by trying to run the C++ language compiler using the following command:
  5. Hit the Enter key and see if you get the result indicated in the screenshot below.
    A GNU compiler message in macOS Terminal

You’ve successfully installed the Xcode Command Line Tools package if you get the same error message about no input files passed.

Upon a successful installation, you’ll find your command line developer tools within the usr/bin/ sub-folder inside the /Library/Developer/CommandLineTools/ folder.

How to Check the Version of Xcode Command Line Tools

You cannot check the version number of Xcode Command Line Tools directly, but you can do so indirectly by checking the version of the Clang compiler in Terminal:


The command will output the version number of the installed command line tools. Match it to the corresponding Xcode release version number on this Wikipedia page to verify that you’ve installed the latest version of Xcode Command Line Tools.

To uninstall Xcode Command Line Tools and remove its folder, execute the following command:

 sudo rm -rf /Library/Developer/CommandLineTools 

You’ll be prompted to enter your Mac’s password as the command requires administrator privileges.

Check that /Library/Developer/CommandLineTools/ is gone on your Mac. To avoid complications, do not manually trash this folder in the Finder.

To confirm you’ve uninstalled Xcode Command Line Tools, try running the GNU compiler by typing “gcc” in Terminal. If you see an error message saying “unable to get active developer directory,” you’ve uninstalled the Xcode Command Line Tools package from your Mac.

Enjoy Command Line Development in macOS

Writing App Store apps for Apple’s platforms requires the complete Xcode integrated development environment that already includes all the required command line tools.

But if you rely on package managers like Homebrew or prefer command-line development, Xcode Command Line Tools is the way to go. At just over a gigabyte, this package comes without the overhead of Xcode, which requires more than 40GB of disk space to install.


Source link

Leave a Reply

%d bloggers like this: