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?
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).
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With