Xcodebuild - how to specify the directory where the project is located, without using cd in it

I use xcodebuild from the command line in the script, but I realized that I can not specify the path to the project I want to create, I have to write cd to the folder where the project is located.

Is there a way to execute the build process without using cd in the directory, or is it the way it should be?

It’s not very important to write cd to the directory and execute xcodebuild, but I’m curious that if you ever need to create a project and you won’t be able to write it to the directory .... It makes no sense to me to not specify the path.

+8
xcodebuild macos
source share
2 answers

You must be in the directory containing the project when xcodebuild starts. If you do not want to contact your current directory, there are several options:

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

or

 (cd $PRJDIR; xcodebuild) 
+4
source share

You can use xcodebuild -project pathtoprojectfile

eg,

xcodebuild -project / IOSprojects / YourProject / YourProject.xcodeproj

+22
source share

Source: https://habr.com/ru/post/651326/


All Articles