29

How do I determine what version(s) of xcode command line tools I have?

I tried doing

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

Is the Apple LLVM version the same as the version of xcode command line tools?

  • +1. It was really hard to craft a Google search to find an answer to this. I searched xcode command line tools installed version but got a lot of irrelevant matches. Btw, did Dog G.'s answer work for you? – Kelvin Jun 15 '16 at 18:20
33

Finding the CLI version number depends on the combination of which particular OS and which particular CLI Tools are installed. One of these should work:

On Yosemite & Mavericks:

pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

on Mountain Lion:

pkgutil --pkg-info=com.apple.pkg.DeveloperToolsCLI
| improve this answer | |
  • 7
    If they ever change the pkg name again, running pkgutil --pkgs | grep -i tools should help locate it. – Kelvin Jun 15 '16 at 18:29
  • 1
    On macOS Catalina com.apple.pkg.CLTools_Executables is still a good package to use for this: pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version version: 11.3.0.0.1.1574140115 – phatblat Dec 13 '19 at 18:37
  • @phatblat: Catalina 10.15.4, fm zsh CL: pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version ==> No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'. Ideas?? – Seamus Apr 18 at 6:11
  • @Seamus, sounds like you don't have the CLI tools installed. That's what I get on 10.15.4 when looking for the old package name: pkgutil --pkg-info=com.apple.pkg.DeveloperToolsCLI No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'. I'm on a fresh 10.15.4 install that I installed the CLI tools on first before installing Xcode 11.4.1: pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version version: 11.4.1.0.1.1586360307 – phatblat Apr 23 at 18:17
  • @phatblat: Thanks for the feedback, but the CL tools are definitely installed - wonder why Apple leaves this versioning business so poorly defined?... Oh scratch that - I think I know the answer :) – Seamus Apr 23 at 20:01
4

For versions of macOS X 10.9 Mavericks and later, this code will provide you the version of both Xcode and Command Line Tools for Xcode, if either are installed:

# Xcode
if pkgutil --pkgs=com.apple.pkg.Xcode >/dev/null; then
    echo Xcode: $(pkgutil --pkg-info=com.apple.pkg.Xcode | awk '/version:/ {print $2}')
else
    echo Xcode: not installed
fi

# Command Line Tools for Xcode
if pkgutil --pkgs=com.apple.pkg.CLTools_Executables >/dev/null; then
    echo CommandLineTools: $(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | awk '/version:/ {print $2}')
else
    echo CommandLineTools: not installed
fi
| improve this answer | |
  • 1
    You can use pkgutil --pkgs=com.apple.pkg.Xcode > /dev/null (and pkgutil --pkgs=com.apple.pkg.CLTools_Executables > /dev/null) to avoid having to grep the result of pkgutil --pkgs. – nohillside Mar 13 at 17:07
  • Thanks for above code! worked well. – jmh Mar 13 at 17:46
2

I'm answering against the more recent version (where the tools actually are in the Xcode.app pkg, but I'm pretty sure that if the path & output returned by xcode-select -p, gcc -v, and llvm-gcc -v/clang -v are harmonious then they should be the same, i.e.

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

$ llvm-gcc -v
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

$ clang -v
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

Note that llvm-gcc is a link to clang,

$ls -al /usr/bin/llvm-gcc
lrwxr-xr-x  1 root  wheel  5 Oct 19  2014 /usr/bin/llvm-gcc -> clang

so the output of llvm-gcc -v and clang -v should be identical although that may or may not be the case for you (see https://stackoverflow.com/a/5708732/602581 for some more details)

| improve this answer | |
  • 1
    The version that these tools output isn't necessarily the same as the Xcode command line tools version. Example, clang --version returns Apple LLVM version 7.3.0 (clang-703.0.31), while Doc G.'s pkgutil command returns version: 7.3.1.0.1.1461711523. – Kelvin Jun 15 '16 at 18:28
2

In terminal do

/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version

example output:

Xcode 10.1
Build version 10B61

(adapted from https://www.garron.me/en/bits/what-xcode-version-am-i-running.html).

| improve this answer | |
  • 2
    Using Mojave here. xcodebuild -version was what I was looking for. – joeytwiddle Feb 25 '19 at 6:11
  • This does not work if Xcode is not installed. If only the CommandLineTools are installed, this path does not exist. – DrStrangepork Mar 12 at 20:20
  • But the question was for the command line tools - aren't they at different version numbers? – Seamus Apr 18 at 6:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .