How to install Xcode Command Line Tools

664,966

Solution 1

Xcode 5.1 and OSX 10.9. (also works with Xcode 5.1.1 + OSX 10.10)

xcode-select --install worked with version 2333, failed with version 2003. So, try xcode-select --install and if that does not work download as described below.

In early February 2014 xcode-select --install has been reporting that "Can't install the software because it is not currently available from the Software Update server". In late February 2014 the command started only displaying help. The solution is to download directly, see "Separate Download" below.

Xcode 5.0.1 and OSX 10.9

With Xcode 5.0.1 and Mavericks 10.9 the command line tool is no longer available through Xcode. Instead they must be downloaded from the Apple Developer Tools site: https://developer.apple.com/downloads/index.action. This requires signing in with a developer account.

Or via terminal (from the release docs): The Command Line Developer Tools package can be installed on demand using "xcode-select --install” and the installed tools will be automatically updated using Software Update. OS X 10.9 is required for this feature. For earlier versions, continue to use the in-app download in Xcode.

Running the command in terminal produces the following GUI:enter image description here

Inside Xcode (5.0)

Xcode includes a new "Downloads" preference pane to install optional components such as command line tools, and previous iOS Simulators. To open this pane click the "Xcode" button in the top left of the screen near the Apple logo, then click "Preferences", then click "Downloads".

Xcode 5.0 screenshot: enter image description here

Xcode 4.x screenshot: screenshot of downloads pane

Separate Download

If you do not have Xcode, they are available as a separate download from Apple:

Go to developer.apple.com/downloads/index.action, and sign in with your Apple ID (the download's free). In the pane on the left, search for "command line tools" and choose the package appropriate to your version of OS X. Requires Mac OS X 10.7.3 or later.

Solution 2

If you take a look into "Console" while trying to pull the Command Line Tools, you will find out that there is actually an "unofficial" link to the Mountain Lion Command Line Tools!

So just try:

http://adcdownload.apple.com/ios/ios_simulator__resigned/cltools_mountainliondp2_march12.dmg

Here is my Console log:

01/04/2012 15:41:54.258 Xcode: [MT] DVTDownloadable: Download failed. Downloadable: {
    dependencies =     (
    );
    fileSize = 141452226;
    identifier = "Xcode.CLTools.10.8";
    name = "Command Line Tools";
    source = "http://adcdownload.apple.com/ios/ios_simulator__resigned/cltools_mountainliondp2_march12.dmg";
    userInfo =     {
        ActivationPredicate = "$MAC_OS_X_VERSION >= '10.8.0' && $MAC_OS_X_VERSION < '10.9.0'";
        InstallPrefix = "/";
        InstalledIfAllSHA1SumsMatch =         {
            "/usr/bin/clang" = 600c35175775a6002452a88f17e00c570cd2e2d0;
        };
        Summary = "Before installing, note that from within Terminal you can use the XCRUN tool to launch compilers and other tools embedded within the Xcode application. Use the XCODE-SELECT tool to define which version of Xcode is active.  Type \"man xcrun\" from within Terminal to find out more.\n\nDownloading this package will install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools.";
        "Xcode.SDKs" =         (
        );
    };
    version = "1.1.1";
}. Error: Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it has been corrupted." (Encountered unknown ampersand-escape sequence at line 18) UserInfo=0x401bc8e60 {NSDebugDescription=Encountered unknown ampersand-escape sequence at line 18, kCFPropertyListOldStyleParsingError=The data couldn’t be read because it has been corrupted.}

Solution 3

Here are links for Command Line Tools, located at Apple Developer Server. You may need an apple developer (Paid/Premium) account to access them. You can download current (stable and beta) Xcode Tools. (It does not need device verification. Just ensure your macOS and XCode Tool/SDK version while choosing your command line tool)

Xcode 13 RC

Once you've latest command line tool installed in your system, set it from Xcode Menu.

(Xcode Menu Items) Xcode ▶ Preferences ▶ Location ▶ Command Line Tool ▶ Select appropriate command line tool

enter image description here

Solution 4

As of big sur..

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

Thanks homebrew maintainers for putting this helpful messaging in brew doctor

Solution 5

The "unofficial" links are also available at

http://developer.apple.com/downloads/

and 403: Forbidden unless logged in with a qualifying developer account. Free accounts have access to everything except prerelease software and full OS installs. In particular, the command-line tools packages that coincide with the release of Xcode 4.4 (the "July 2012" packages) were posted on July 27, for both Lion and Mountain Lion.

Unlike log files, deep-linking Web pages, and the Xcode Preferences window, this page also links to lots of other useful downloads for free and paid developers alike, including everything else that has been unbundled from Xcode (audio tools, accessibility tools, etc.), OS X kernel debug builds, and release versions of Xcode back to 1.0.

Share:
664,966
Scott Wisniewski
Author by

Scott Wisniewski

Updated on July 08, 2022

Comments

  • Scott Wisniewski
    Scott Wisniewski almost 2 years

    How do I get the command-line build tools installed with the current Xcode/Mac OS X v10.8 (Mountain Lion) or later?

    Unlike Xcode there is no installer, it's just a bundle.

    It looks like all the command line tools are in the bundle, under Contents/Developer, but none of the appropriate environment variables are set to use them.

    Is there a script I can run that will set-up my environment to support building from the command line?

  • Trung Lê
    Trung Lê about 12 years
    You could download the standalone Command Line Tools and have access to everything that osx-gcc-installer provides. In fact, kenneth blogged about this kennethreitz.com/xcode-gcc-and-homebrew.html
  • vinzenzweber
    vinzenzweber about 12 years
    this didn't work for me! I found another way of dealing with it! see stackoverflow.com/a/9964905/300694
  • Irae Carvalho
    Irae Carvalho almost 12 years
    You can also login at developer.apple.com (fee account is fine) and download it there. I was the only way for me.
  • Felipe Lima
    Felipe Lima almost 12 years
    I wasnt able to download neither through developer.apple.com, neither XCode. This worked perfectly. Thanks!!
  • Tilo
    Tilo almost 12 years
    works like a charm! Ridiculous that the command line tools are not installed by default!
  • pagid
    pagid over 11 years
    Just to add sth here: once registered, go to developer.apple.com/xcode -> click on "View downloads" and find the Command line tools in the list - hope this saves some time for someone.
  • Matt Hudson
    Matt Hudson over 11 years
    You can also make an alias in your .bashrc file to make 'git' use 'xcrun git' so that your git command is the same as everyone else's cocoanetics.com/2012/07/….
  • DeaconDesperado
    DeaconDesperado about 11 years
    I guess I'm only allowed to speak for myself, but from a person coming over from a sane Unix distro, the idea that your main system compiler is installed this way is pure madness.
  • leoj
    leoj about 11 years
    The usefulness of the link seems to have expired: Your session has expired. Please return to the ADC Member Site and attempt to download the file again. If you feel you received this message in error, please reference this code when contacting the ADC Support Team: V6
  • denis
    denis about 11 years
    After login on developer.apple.com/xcode, register Q+A (stupid) gave "Safari can't open, too many redirects trying to open developer.apple.com/donwloads/index.action".
  • andy4thehuynh
    andy4thehuynh almost 11 years
    @leoj3n : What file am I trying to download? My session expired too but I was able to re-log in. I already downloaded the latest command line tools from April
  • dan
    dan over 10 years
    → DeaconDesperado: you're not alone 😠. Please fill a feedback report: apple.com/feedback/macosx.html
  • orome
    orome over 10 years
    Is this true? Updating Xcode through the AppStore seems to install command line tools as well. Also: it's unclear from the above whether one should expect to see the tools in the 5.0.1/10.9 Downloads preference pane (and if so whether the absence means they're already installed).
  • Hanxue
    Hanxue over 10 years
    This is the OS X Mavericks version, current as of Nov 2013 adcdownload.apple.com/Developer_Tools/…
  • Solomon Closson
    Solomon Closson over 10 years
    I don't see Command Line Tools in Preferences -> Downloads. Does that mean it is already installed?? How do you check if it is installed or not?
  • Solomon Closson
    Solomon Closson over 10 years
    I am using XCode 5.0.2, and the Downloads tab exists, but just doesn't show Command Line Tools anywhere that I can see. So, am I right in thinking that they don't offer this anymore?
  • zaph
    zaph over 10 years
    @Solomon The first paragraph states that things changed and in Xcode 5.0.1 and above. To be clear, there is a preferences downloads tab but there is not an option in it to download the command line tools. Use "xcode-select --install" in the terminal.
  • DonnaLea
    DonnaLea over 10 years
    @raxacoricofallapatorius and Solomon Closson, I had the same situation, it wasn't showing in the panel. I ran "xcode-select --install" and it required downloading. After having installed it, it still does not display in the panel, so not in the panel doesn't indicate anything. I have Xcode 5.0.2.
  • Queenvictoria
    Queenvictoria over 10 years
    If you're using OS X 10.9 and have run "xcode-select --install" you can follow that with "softwareupdate -l" which will show you what is about to be installed and "sudo softwareupdate -i -a" to go ahead and install what you have selected.
  • dawg
    dawg about 10 years
    @DeaconDesperado: It is worse -- you have to use sudo to accept the command line EUL before it will compile anything at all. If you have some sort of make file, sometimes it fails silently if you don't run sudo and accept the @#&& License Agreement!!! Epic oversight on Apple's part...
  • Jonathan García
    Jonathan García about 10 years
    "From OS X 10.9 onward, if Xcode is already installed in OS X then Command Line Tools becomes installed as well" osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/‌​…
  • alexserver
    alexserver almost 10 years
    I got "Cannot install the software because it is not currently available from the Software Update Server"
  • Dave
    Dave over 9 years
    Note: if you're getting "Cannot install the software because it is not currently available from the Software Update Server" have a look at Grey's answer (not the picked answer, but further down) on this page: stackoverflow.com/questions/19691701/… . This solved my issue.
  • noɥʇʎԀʎzɐɹƆ
    noɥʇʎԀʎzɐɹƆ almost 8 years
    This is the answer that worked for me. This doesn't require a paid account and doesn't error out like the answers above.
  • DawnSong
    DawnSong over 4 years
    The latest website for download "Command Line Tools", developer.apple.com/download/more
  • vhs
    vhs over 4 years
    Thank god for people like Kenneth.
  • Victor
    Victor about 4 years
    xcode-select --install works even in MacOS Catalina 10.15.3
  • Harsh Patel
    Harsh Patel over 3 years
    Not working above OS X Lion. don't waste your time to go and download
  • August
    August over 3 years
    This answer worked for me pointing to 12.0.1 > I got an error trying to rebuild a package in Atom (text editor) saying there were no command line tools. I launched Xcode prefs and the command line tools selector was blank! I set the selector to 12.0.1, switched back to Atom, and tried rebuilding the package and it worked.