How can I use xcodebuild in command line?

13,494

Solution 1

The installer put mine in

/usr/bin/xcodebuild

You can also find it in the application bundle:

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

Solution 2

/usr/bin/xcodebuild only calls the xcodebuild command from the developer tools directory given by xcode-select. To find out the current developer tools directory as given by xcode-select run

xcode-select -print-path

I fixed the issue by changing that path executing

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

Which is where my developer tools are. You should change /Applications/Xcode.app to wherever your Xcode application is.

Share:
13,494

Related videos on Youtube

Spark
Author by

Spark

I choose I like!

Updated on June 28, 2022

Comments

  • Spark
    Spark almost 2 years

    I'm a newbie to xcode. I'm using xcode 4.3 with lion. I want to use xcodebuild in command line, but it report "no such file". I searched it with Finder, but no result.

    What is this file's path? Does it exist in the Xcode.app? Can I search files in a .app package?

    Additional info: When I typed "which xcodebuild", it return /usr/bin/xcodebuild. Enter this folder, and type xocdebuild, it still return Error:

    Can't run /Applications/usr/bin/xcodebuild (no such file).
    
  • Spark
    Spark about 12 years
    I have checked it, and make sure it installed.
  • Spark
    Spark about 12 years
    I find it, but still cannot work, aways report: Can't run /Applications/usr/bin/xcodebuild (no such file).
  • Conrad Shultz
    Conrad Shultz about 12 years
    Post exactly what you are typing. Note that "/Applications/usr/bin/xcodebuild" is NOT what I wrote, and is a totally bogus location.
  • Conrad Shultz
    Conrad Shultz about 12 years
    (I'm not saying you're messing things up, though. It's possible that you have a broken symlink somewhere, for example.)
  • NSResponder
    NSResponder about 12 years
    Spark, look carefully at what you wrote. You're leaving "Xcode.app" out of your path.
  • Spark
    Spark about 12 years
    I just type "xcodebuild". It seem mac aways redirect my command to a nonsexist path "/Applications/usr/bin/xcodebuild"
  • Conrad Shultz
    Conrad Shultz about 12 years
    But you're saying that "which xcodebuild" results in "/usr/bin/xcodebuild"? Maybe you have a bad symlink... what do you get if you "ls -l /usr/bin/xcodebuild"?
  • Spark
    Spark about 12 years
    Thanks all guys, the problem solved :) The xcodebuild in /usr/bin/xcodebuild is corrupted. I made a link from /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuil‌​d, it can work now.