13

I am using xcodebuild from command line in a script, but I realized that I cannot specify the path of the project that i wanna build;I am forced to cd in the folder where the project is.

Is there a way to accomplish the build process without having to cd in the directory, or this is how it must be?

Is not a big deal to cd into the directory and execute xcodebuild, but I wonder what if someday you need to build a project and you cannot cd into the directory....It doesn't really make sense to me to not being able to specify the path.

  • 1
    I don’t really get the ‘you cannot cd into the directory’ part. What do you mean by that? –  Jan 21 '11 at 00:30
  • If you can't cd into the directory, I think you've got more immediate problems than xcodebuild. – Chuck Jan 21 '11 at 00:46

2 Answers2

27

You can use xcodebuild -project pathtoprojectfile

eg

xcodebuild -project /IOSprojects/YourProject/YourProject.xcodeproj

Vishnu
  • 4,377
  • 7
  • 26
  • 40
6

You must be in the directory containing the project(s) when you run xcodebuild. If you don’t want to mess with your current directory, there a couple of options:

/bin/sh -c "cd $PRJDIR; xcodebuild"

or

(cd $PRJDIR; xcodebuild)