15

If I create a new application project, the build settings look something like this:

enter image description here

It claims to be using a build dir build/Debug-iphoneos. I assume this is relative to the project directory? In reality, the project is compiled to the "derived data" directory, under ~/Library/Developer/Xcode/DerivedData/CryptoTest2-abc...

So what is going on here? Is this build setting simply ignored? What is the build setting that controls the output directory?

Rob N
  • 15,024
  • 17
  • 92
  • 165

2 Answers2

23

This build setting is actually relative to the Derived Data setting. You can change this setting if you go to Xcode > Preferences > Locations, and change the Derived Data directory setting to whatever suits your needs (Default, Relative or Custom). Xcode settings illustration

You can also specify this on a per project-basis, if you specify an absolute path for that settings:

  • You can either hardcode a path such as /build/${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}, then the project will be built into the folder build in the root folder.
  • Or can you can choose to prepend the existing path with another environment variable. For example, to make the path relative to your project/workspace (As you would expect), you can prepend the original value with ${SRCROOT}/, effectively creating a build folder at the root of your project/workspace.

Settings that can be substitued in ${<setting>} are called Build settings, and are set automatically by Xcode/xcodebuild whenever you start building your project. Apple maintains a list of the available build settings here:
http://help.apple.com/xcode/mac/8.0/#/itcaec37c2a6

Stéphane Copin
  • 1,888
  • 18
  • 18
  • The link of the build settings reference is dead. Do you know where to find the current one? Thanks! – Damnum Oct 18 '16 at 08:05
  • 1
    @Damnum just edited the post and fixed the link, Apple updated their doc – Stéphane Copin Oct 24 '16 at 14:27
  • [Is there a way to make it per project and save that configuration in pbxproj files?](//stackoverflow.com/questions/43601115/how-to-make-deriveddata-or-build-location-in-xcode-to-be-relative-to-project) – Pavel P Apr 25 '17 at 03:48
2

Go to File -> Workspace Settings -> Advanced and select Legacy

Krzysiek
  • 185
  • 1
  • 10
  • This is the correct answer. After select Legacy, you can set Build Products Path(in your own target's Build Settings) relative to you project directory. – ideawu Jan 02 '18 at 04:39
  • 3
    THANK YOU! I spent full day trying to understand what am I doing wrong. Working with XCode is the most frastrating thing I ever done in my life – PazO Jun 10 '20 at 13:09