The man page for xcodebuild
reads:
Run xcodebuild from the directory containing your project (i.e. the directory containing the project
In my project, setting SYMROOT
turned out to be sufficient to build the project in a different location, leaving other locations untouched.
From Apple's Xcode Build Setting Reference (which I came across via another answer here, thanks!):
SYMROOT (Build Products Path)
Description: Directory path. Identifies the root of the directory hierarchy that contains product files and intermediate build files. Product and build files are placed in subdirectories of this directory.
...
Affects: BUILT_PRODUCTS_DIR, CONFIGURATION_BUILD_DIR (...)
This setting is also mentioned a few times in the xcodebuild
man page:
Available actions are:
build: Build the target in the build root (SYMROOT)...
clean: Remove build products and intermediate files from the build root (SYMROOT)....