13

I know the way to change the location of DerivedData using Xcode (Preferences->Locations->DerivedData..).

However the Mac that I am trying to build on is in a remote location with only ssh access. I want to build a specific project where I want to keep the DerivedData location relative to the project.

Whenever I build the project using xcodebuild, the files end up generating under /Users/builduser/Library/Developer/Xcode/DerivedData however I want them under '$PROJECT/target/DerivedData'

What is the command line equivalent to changing the DerivedData location setting as can be done via XCode?

2 Answers 2

20

The Xcode UI's DerivedData setting is passed to xcodebuild via the -derivedDataPath argument. From man xcodebuild:

-derivedDataPath path
   Overrides the folder that should be used for derived data when performing a build action on a scheme in a workspace.

While it isn't clear what your goal is with changing the DerivedData path, you should be aware that there are some additional settings you can adjust in your app's build configuration to affect where the final build gets deployed. One of the phases of the build is the install phase which can move the final artifact(s) elsewhere. Settings that control these behaviors can be found under the 'Deployment' build settings group. See DSTROOT, INSTALL_PATH, and DEPLOYMENT_LOCATION for additional options that may be helpful for reorganizing where your products get deployed.

Sign up to request clarification or add additional context in comments.

8 Comments

But do you know where Xcode writes his default config for the DerivedData when configured from the UI, so we don't have to specify it from the xcodebuild command-line?
@dbernard Toss up a new SO question as this one was very specifically focused on modifying config via the CLI. I'd be more than happy to give it an answer.
in my opinion the question asked by the poster "What is the command line equivalent to changing the DerivedData location setting as can be done via XCode?" is what I just asked. :)
@dbernard is clearly more context required than available in 550 characters; I'd be happy to help but not in the comments section of another question -- give the SO community the space to respond in a new question.
I definitely agree, but since this SO thread was one of the first search hit I got, may I suggest you Edit your answer to add a complement information for those looking to change the default config from command line? If you know the answer of course. ;)
|
2

You probably should set this on a project basis, but if you need to change the Xcode default without going to the UI:

There's a plist file under ~/Library/Preferences/com.apple.dt.Xcode.plist

You can see and the change content via PlistBuddy:

/usr/libexec/PlistBuddy -c print ~/Library/Preferences/com.apple.dt.Xcode.plist and you can see the field: IDECustomDerivedDataLocation = DerivedData

If it's not set, you can just add it using PlistBuddy:

/usr/libexec/PlistBuddy -c "Add IDECustomDerivedDataLocation string DerivedData" ~/Library/Preferences/com.apple.dt.Xcode.plist

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.