Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command line option to change Xcode DerivedData location

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?

like image 278
Neo Avatar asked Oct 09 '15 18:10

Neo


People also ask

Where is Xcode derived data folder?

DerivedData is a folder located in ~/Library/Developer/Xcode/DerivedData by default. It's the location where Xcode stores all kinds of intermediate build results, generated indexes, etc. DerivedData location can be configured in Xcode preferences (Locations tab).

How do I remove derived data from terminal?

Delete Derived Data Choose Window -> Organizer. Select the Projects tab. Select your project on the left. Next to the Derived Data line, there click the Delete button.


2 Answers

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.

like image 92
Bryan Musial Avatar answered Nov 15 '22 07:11

Bryan Musial


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

like image 24
Jeff Chong Avatar answered Nov 15 '22 07:11

Jeff Chong