93

I have installed the Command Line Tools:

$ xcode-select --print-path
/Library/Developer/CommandLineTools

However, when anything tries to use xcodebuild, I get the following error:

$ /usr/bin/xcodebuild
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

On Mountain Lion it was possible to use this without installing the whole of Xcode, rather just the Command Line Tools. Is it possible to do this on Mavericks? How can I get it working?

N.B. This is on a clean install of Mavericks.

Update: just to show, I do have the Command Line Tools installed:

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
  • 1
    Running into the same problem here trying to build some node modules. Hopefully a quick workaround is available. – rossipedia Oct 27 '13 at 00:12
  • I created an issue on `node-gyp` as that's the source of my problem: https://github.com/TooTallNate/node-gyp/issues/341 –  Oct 28 '13 at 09:53
  • Maybe you have to install Xcode. Thats how my gcc --version looks like Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix – Martin Christmann Oct 28 '13 at 17:32
  • 1
    Maybe you are right, just odd that it wasn't necessary on Mountain Lion with Command Line Tools installed. –  Oct 28 '13 at 18:29
  • I assume you did `xcode-select --install`. With Xcode installed `xcode-select --print-path` prints `/Applications/Xcode.app/Contents/Developer` – mb21 Nov 03 '13 at 14:49

9 Answers9

65

I know that this is a late answer, but in my case this command solved the issue:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Juanan
  • 1,385
  • 11
  • 26
  • 16
    note that the question is about building with command line tools install. By switching to Xcode.app, you are building via Xcode (what the question is trying to avoid installing). – bryanmac Oct 29 '14 at 04:09
23

It appears that OSX has changed xcodebuild to require XCode to be installed, where before it functioned properly with only the OSX Command Line Tools installed.

Old semi-related answer

Many people ran into this with Node. Node's build tool, gyp, uses xcodebuild to prepare for compiling node packages. Mavericks has changed the behavior of xcodebuild so that it no longer works properly with gyp. This is being fixed at the moment. See the node-gyp issue

Once the changes have been deployed to NPM, you will be able to install the new node-gyp package and compile properly. You will also need to update your NPM version once the changes are incorporated into NPM.

loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
  • no idea why this is linked with node, I am trying to build something else with Xcode – zinking Jul 04 '14 at 06:43
  • exactly, still xcodebuild is firing error when you call it from command line... I actually downloaded the latest command line tools from apple developer website https://developer.apple.com/downloads/index.action# – alexserver Jul 28 '14 at 17:05
16

Please first go to finder, next select Applications from left panel, next look for Xcode, and check if its name is Xcode or Xcode-Beta

If name is Xcode-Beta then enter this command in Terminal:

sudo xcode-select -switch /Applications/Xcode-Beta.app/Contents/Developer

If name is Xcode then enter this command:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Hope this answer might help for users with Beta version of Xcode

Thanks

Irfan Anwar
  • 1,878
  • 17
  • 30
9

This issue was due to xcode-select developer directory pointing to /Library/Developer, which only contained the folder CommandLineTools. To this end, the error message is complaining about not the directory not being the same as Xcode.

Two tested solutions:

  1. (Re) Install Xcode.

  2. Point xcode-select to the Xcode Developer Directory using the following command:

    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
    

References:

How to fix error like “xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory * BROKEN LINK *

xcode-select active developer directory error

carlodurso
  • 2,886
  • 4
  • 24
  • 37
2

I reinstalled Xcode from App Store which solved this issue. I guess my previous installation is not complete install

zinking
  • 5,561
  • 5
  • 49
  • 81
1

There's also a GUI to change the Command Line Tools path in Xcode > Preferences > Locations:

Xcode > Preferences > Locations

I just had this issue after upgrading to Xcode 10.3 while keeping an older copy of 10.2.1 in a sub-folder in Applications. When I opened this Locations panel the selection for Command Line Tools was blank, but I was able to choose between the two versions installed:

Command Line Tools selection dropdown

I tend to go with the GUI option if it's available instead of copying in sudo commands from SO.

suite22
  • 476
  • 3
  • 16
0

If you use XCode2: sudo xcode-select --switch /Applications/Xcode\ 2.app/Contents/Developer

Pay attention to the "\" to escape the space.

turibbio
  • 41
  • 1
  • 2
  • 8
0

Today I had this issue and the problem was I was using a manual install of xcode and had the file named Xcode8.3.2.app instead of Xcode.app. Renaming the app fixed the issue of xcode-select complaining. This seems to indicate the regular appname is on its search path but variants are not.

AnneTheAgile
  • 9,932
  • 6
  • 52
  • 48
-3

AFAIK, command line tools in Mavericks are installed into /Applications/Xcode.app/Contents/Developer which tends to imply that Xcode is required. Undocumented feature probably.

moreaug44
  • 27
  • 2