Is it safe to delete Xcode DerivedData?

DerivedData is where Xcode keeps everything it builds, and it grows with every project and every Xcode version. On a busy Mac it reaches 20 GB or more. Deleting it is safe; here’s what that costs you.

Diskly suggesting Xcode build data, 21.4 GB, as safe to remove because Xcode recreates it on the next build

In short

Yes. DerivedData holds build products, indexes and logs that Xcode recreates on the next build. You lose one slower build and some indexing time per project, never your code. Quit Xcode first, then delete ~/Library/Developer/Xcode/DerivedData.

What’s inside DerivedData

One folder per project, named after it, holding the compiled app, intermediate build files, the index Xcode uses for autocomplete and jump-to-definition, and build logs. Old projects you haven’t opened in months keep their folders until you remove them.

What you lose by deleting it

  • The next build of each project is a full one, so it takes longer.
  • Xcode re-indexes each project when you open it. Autocomplete may be slow for a few minutes.
  • Old build logs go. If you’re investigating a build problem, keep them until you’re done.

How to delete it

  1. Quit Xcode.
  2. In Xcode › Settings › Locations, click the arrow next to the Derived Data path to open it in Finder. Or use Go › Go to Folder with ~/Library/Developer/Xcode/DerivedData.
  3. Move the project folders you don’t need to the Trash, or all of them.

Or in Terminal, with Xcode closed:

Terminal
rm -rf ~/Library/Developer/Xcode/DerivedData/*

This skips the Trash, so check the path before you press Return.

For just the project you have open, Product › Clean Build Folder (Shift-Command-K) clears its build products without leaving Xcode.

Other Xcode folders worth a look

  • iOS DeviceSupport (~/Library/Developer/Xcode/iOS DeviceSupport). Debugging files copied from every iPhone or iPad you’ve connected, one folder per iOS version. Safe to remove; Xcode copies them again when you connect that device.
  • Archives (~/Library/Developer/Xcode/Archives). Builds archived for release. Keep the ones for versions people still use: you need them to read those versions’ crash reports.
  • Simulators for iOS versions you no longer have installed.
  • Simulator runtimes. Whole copies of iOS, several gigabytes each. Remove old ones in Xcode › Settings › Components.
Terminal
xcrun simctl delete unavailable

Removes simulated devices whose iOS version is no longer installed.

Terminal
xcrun simctl runtime list

Lists installed simulator runtimes and their sizes; remove one with xcrun simctl runtime delete followed by its identifier.

Questions people ask

Is it safe to delete Xcode DerivedData?

Yes. It holds build products, indexes and logs that Xcode recreates on the next build. You lose one slower build and some indexing time, nothing you wrote.

Where is Xcode DerivedData?

In ~/Library/Developer/Xcode/DerivedData. Xcode › Settings › Locations shows the path and opens it in Finder.

Does Clean Build Folder delete DerivedData?

Only the build products of the project you have open. Other projects’ folders, and their indexes, stay.

Keep reading

All guides →