Search code examples
xcodeprojects-and-solutions

How to make DerivedData or Build Location in Xcode to be relative to project


I have multiple pbxproj files in my xcode workspace. By default all build outputs and temporary .obj files go to some random location in xcode and I would like to make all that output goes to path relative to where I have all the source files. We have uniform layout for all build output across different build targets except xcode outputs all results to some random location.

At the same time this has to be done in a way so that this change could be stored in versioning system (e.g. git) and so that this change would be picked up on other developer machines. That means I don't want to change XCode's global preferences to change DerivedData path.

When I tried to change per-project settings there are options to change DerivedData location or in "Advanced" dialog I could make "Build Location" to be "Custom" and "Relative to Workspace" it works, ... but it doesn't work properly, as this change isn't reflected in pbxproj files, but creates some userspecific configs all over the place which do not make sense to be added to git as these files even have my username in their paths.


Solution

  • Don't bother trying to configure DerivedData location, this route leads nowhere. The only way to do it seems to use custom .xcconfig: