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.

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

2 Answers 2

27

You can use xcodebuild -project pathtoprojectfile

eg

xcodebuild -project /IOSprojects/YourProject/YourProject.xcodeproj

0
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)
4
  • 4
    You could also try using pushd and popd instead of cd.
    – splicer
    Jan 21, 2011 at 0:59
  • @splicer Nice. I didn't know about those.
    – user557219
    Jan 21, 2011 at 1:01
  • Thanks for the replies! So indeed is not possible to do it without being in the directory where the project lives, but i can use these solutions that you mentioned!
    – user393267
    Jan 21, 2011 at 1:53
  • 1
    Use -project to specify path. Sep 20, 2016 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.