Separate build directory using xcodebuild

Dave Mateer picture Dave Mateer · Feb 11, 2011 · Viewed 16.3k times · Source

The man page for xcodebuild reads:

Run xcodebuild from the directory containing your project (i.e. the directory containing the projectname.xcodeproj package).

I would like to keep my source directory (which is a Subversion external) clean and unmodified, and build my object files and executables to a location completely outside of the source directory.

Is there any way to build into a separate build directory from a terminal using xcodebuild like you can do with make tools or even msbuild on Windows?

Answer

Dave Mateer picture Dave Mateer · Feb 11, 2011

You can set build settings from the command line. The CONFIGURATION_BUILD_DIR will set the build directory. For example:

xcodebuild -project YourProject.xcodeproj -configuration Debug -target All ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES CONFIGURATION_BUILD_DIR=../some/other/dir

A reference is found on Apple's site: