Xcode Command Line Tools

Also known as: xcode-select

On this page 8

Xcode Command Line Tools is a standalone developer package for macOS that installs the compilers, build utilities, version control client and SDK headers needed to build software from the command line, without installing the full Xcode application. It is managed with the xcode-select utility and is the usual prerequisite for Homebrew, MacPorts and most open-source build workflows on a Mac.

In Terminal and scripting work, the package is the bridge between a plain macOS installation and a working Unix development toolchain. A fresh Mac ships with stub commands such as git and clang that only trigger an installation prompt; the real binaries arrive with this package.

What the Command Line Tools package installs

The package places a complete LLVM-based toolchain in a single directory, normally /Library/Developer/CommandLineTools. Inside it sit the Apple Clang compiler, the linker, the archiver, Git, make and a macOS SDK with the system headers and library stubs that compilers need to target the current operating system.

The following table lists the components that matter most in daily work and what each one does.

ComponentCommandPurpose
Apple Clangclang, clang++, ccCompiles C, C++ and Objective-C code
LinkerldCombines object files into executables and libraries
GitgitVersion control client used by Homebrew and most projects
MakemakeRuns build rules defined in a Makefile
macOS SDKxcrun --show-sdk-pathProvides system headers and framework stubs
Binary utilitiesotool, lipo, strip, nmInspect and modify Mach-O binaries
Swift compilerswift, swiftcBuilds Swift packages and scripts
Main components of Xcode Command Line Tools

Commands in /usr/bin such as /usr/bin/git are shims, not the actual tools. Each shim asks xcrun to locate the active developer directory and then runs the matching binary from there. This indirection layer is why the same command can resolve to the standalone package on one Mac and to the full Xcode bundle on another.

Installing and selecting the toolchain with xcode-select

The standard installation command is xcode-select --install, which opens a software update dialog and downloads the package from Apple. The same dialog appears automatically the first time a user runs a shim such as git or make on a Mac without developer tools.

The xcode-select utility also controls which developer directory is active. This matters when both the standalone package and one or more copies of Xcode are installed, because only one toolchain answers the shims at a time.

CommandEffectRequires administrator
xcode-select --installStarts the download and installationNo
xcode-select -pPrints the active developer directoryNo
sudo xcode-select -s <path>Switches the active toolchainYes
sudo xcode-select --resetRestores the default pathYes
softwareupdate --listShows pending tool updatesNo
pkgutil --pkg-info=com.apple.pkg.CLTools_ExecutablesReports the installed package versionNo
Common xcode-select and related commands

In managed fleets, administrators often avoid the interactive dialog. They trigger a headless installation through softwareupdate by creating a temporary marker file that makes the package appear in the update catalog, then installing it by its label. This approach suits MDM scripts and provisioning workflows where no user is present to click through a prompt.

Command Line Tools compared with full Xcode

The standalone package is a subset of Xcode, not a lighter edition with different behavior. Both share the same compiler and SDK versions for a given release, but only full Xcode includes the IDE, simulators, Interface Builder and the tools for signing and submitting apps to the App Store.

The comparison below shows when each option is the right choice.

AspectCommand Line ToolsFull Xcode
Download sizeSeveral hundred megabytesMany gigabytes, often over 10 GB installed
Install location/Library/Developer/CommandLineTools/Applications/Xcode.app
Compilers and GitIncludedIncluded
iOS and watchOS SDKsNot includedIncluded
Simulators and IDENot includedIncluded
Typical userHomebrew users, script authors, backend developersApp developers for Apple platforms
Standalone tools versus the full Xcode application

Some tools need full Xcode even for command-line use. Building iOS apps with xcodebuild, running UI tests or using simctl all fail with the standalone package alone, and the error usually states that the active developer directory is a Command Line Tools instance.

Role in Homebrew, MacPorts and scripting

Package managers depend on the toolchain because they compile software from source whenever a prebuilt binary is unavailable. Homebrew checks for the package during installation and refuses to continue without it, while MacPorts documents it as a mandatory dependency for building ports.

Scripting languages also rely on it indirectly. Installing a Python package with native C extensions, a Ruby gem with compiled parts or a Node.js module built with node-gyp requires a working compiler and the SDK headers. When the tools are missing or broken, these installers report errors about missing headers such as stdio.h, which point to an incomplete or mismatched SDK rather than a problem in the package itself.

Updates, version mismatches and common problems

Apple delivers new versions through Software Update and the softwareupdate command. Major macOS upgrades frequently leave the old package in place, and the shims then fail with an invalid active developer path error until the tools are reinstalled for the new system.

The table below maps frequent symptoms to their causes and the usual fix.

SymptomLikely causeFix
invalid active developer pathTools removed or broken by a macOS upgradeRun xcode-select --install again
Missing system headersSDK path not found or outdatedReinstall the tools or check xcrun --show-sdk-path
Wrong compiler versionActive path points to an old XcodeSwitch with sudo xcode-select -s
xcodebuild requires XcodeOnly the standalone package is activeInstall full Xcode and select it
Install dialog never finishesUpdate server or network issueInstall via softwareupdate or Apple Developer downloads
Typical failures and how to resolve them

A clean reinstall means removing /Library/Developer/CommandLineTools with administrator rights and running the installation command again. This is the most reliable repair for corrupted installations, but it should be done only after confirming that no running build depends on the current directory.

Security and system integrity considerations

The package is signed and distributed by Apple, and its files sit outside the sealed system volume, so they can be updated without affecting System Integrity Protection. Installing it does not weaken Gatekeeper, but it does add a compiler and Git to the attack surface, which some security baselines restrict on kiosks or shared machines.

  • Install the tools only on Macs that actually build or compile software.
  • Keep them current through softwareupdate, because Git and Clang receive security fixes in tool updates.
  • Avoid replacing Apple shims in /usr/bin; adjust PATH instead when another toolchain is required.

Understanding it simply

A new Mac can browse the web and edit documents, but it cannot build programs from source code out of the box. Xcode Command Line Tools is the toolbox that adds that ability. It brings a compiler that turns code into programs. It adds Git for tracking changes and a few helper utilities.

Full Xcode is like a complete workshop with every machine installed. The Command Line Tools package is the portable toolbox. It is much smaller and enough for most jobs in Terminal. Tools such as Homebrew ask for it first.

Applied in practice

A data analyst receives a new MacBook and wants to install Python libraries and a few utilities through Homebrew. The Homebrew installer stops and explains that developer tools are missing, so the analyst runs xcode-select --install, accepts the license and waits about ten minutes for the download of several hundred megabytes.

After installation, xcode-select -p reports /Library/Developer/CommandLineTools, Homebrew completes its setup and a Python package with native C extensions compiles without errors. Six months later, a major macOS upgrade breaks git with an invalid developer path message; running the same installation command once more restores the toolchain in minutes, without ever downloading the much larger full Xcode application.