34

If I try to run xcodebuild from the command line, I receive the message:

error: can't exec '/Developer/usr/bin/xcodebuild' (No such file or directory)

But, xcrun appears to work.

Does this mean xcodebuild is not installed? I installed the command line tools in Xcode 4.3.1 Is there something I need to do to get this to work?

smci
  • 32,567
  • 20
  • 113
  • 146
Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190

1 Answers1

99
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Kurt Revis
  • 27,695
  • 5
  • 68
  • 74
  • 1
    Thanks for your reply. It seems that xcodebuild is located within /Applications/Xcode.app/Contents/Developer/usr/bin. But why do I need to run this command? Why can't I directly run xcodebuild from the command line like xcrun... ? Thanks. – Rahul Iyer Mar 24 '12 at 04:14
  • 2
    I think I understand why - Because Xcode 4.3.1 is an app now, and as a result all tools should be in that location. – Rahul Iyer Mar 24 '12 at 04:27
  • thanks, this one bit me when I tried to install libsdl on Macports – boxofrats Mar 26 '12 at 22:26
  • 2
    If you have a previous rev of Xcode it was installed under /Developer. As you point out, with 4.3.1 it is now an application located in /Applications and the stuff under /Developer is now embedded deep within. There is a lot of legacy environment in the system as a whole, and in your user home that will point to the old location. xcode-select fixes this. – Andrew Wolfe Mar 30 '12 at 17:45
  • 3
    You don't need to include the whole path to Developer, just do `sudo xcode-select -switch /Applications/Xcode.app/` and it determines the correct location. – ThomasW Jun 01 '12 at 06:46
  • 1
    I tried above command and then execute below command still it is giving same error /Applications/Xcode.app/Content/Developer/usr/bin/xcodebuild -project Monotouch.TTTAttributedLabel-master/TTTAttributedLabel.xcodeproj -target TTTAttributedLabel -sdk iphonesimulator -configuration Release clean build – Mahesh Bansode Jun 11 '14 at 15:37
  • Great answer, even 6 years later I find this to still work. – a2f0 Mar 05 '18 at 18:38