DUSTPAN

How to clear Xcode DerivedData (and keep it from growing back)

Xcode's DerivedData folder is the single biggest thing most Mac developers never look at. Here is where it lives, what is safe to delete, the three ways to clear it, and how to stop doing this by hand.

What DerivedData is

Every time Xcode builds, it writes the results somewhere it can reuse them: compiled objects, linked products, the index that powers jump-to-definition, module caches, logs and test results. All of that goes into DerivedData, one subfolder per project or workspace, named like MyApp-abcdefghijklmnopqrstuvwxyz.

None of it is source. Everything in there is regenerated from your project the next time you build, which is exactly why it is safe to delete and exactly why it grows: Xcode writes generously and never cleans up after old projects, old branches or old simulators.

Where it is

By default:

~/Library/Developer/Xcode/DerivedData

If you have changed it, the current location is in Xcode under Settings → Locations → Derived Data, and the small arrow next to the path opens it in Finder.

How big is it right now?

du -sh ~/Library/Developer/Xcode/DerivedData

Tens of gigabytes is normal on a machine that has been developing for a year. Over 100 GB is not rare. Each project's folder is listed separately, so this shows where it went:

du -sh ~/Library/Developer/Xcode/DerivedData/* | sort -h

Is it safe to delete?

Yes. Your projects, settings, signing identities and source code live elsewhere. Deleting DerivedData costs you one slow build per project while Xcode rebuilds, and the index comes back on its own after that build.

Two things to know while Xcode is running. Deleting the folder of a project Xcode currently has open can confuse the build system until you restart Xcode, so either quit Xcode first or leave the open project's folder alone. And if you are debugging an app out of DerivedData, deleting its folder pulls the executable out from under the debugger. Quitting Xcode first sidesteps both.

Three ways to clear it

1. From Xcode, one project at a time

Product → Clean Build Folder (⇧⌘K) deletes the build products for the current project. It is the gentlest option and the one to try first when a build is acting strangely. It does not touch other projects or the shared module cache, so it rarely gets much space back.

2. From Finder

  1. Quit Xcode.
  2. In Finder choose Go → Go to Folder… (⇧⌘G) and paste ~/Library/Developer/Xcode/DerivedData.
  3. Select everything inside the folder and move it to the Trash. Keep the DerivedData folder itself; Xcode expects it to exist.
  4. Empty the Trash. Until you do, the space is not actually free.

3. From Terminal

Quit Xcode, then:

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

The trailing /* matters: it empties the folder instead of removing it. If you use a custom location, substitute that path. There is no undo, which is the one argument for the Finder route if you are unsure.

What else fills ~/Library/Developer

DerivedData is usually the largest item but not the only one. If you are still short on space after clearing it, these are the other regenerable folders, roughly in order of size:

Why it grows back, and how to stop cleaning by hand

DerivedData refills because that is its job. Every branch switch, every dependency bump and every Swift toolchain update invalidates part of it, and Xcode keeps the old pieces around. On a busy machine it is back to tens of gigabytes within weeks, which is why most people clear it only when the disk-full dialog forces them to.

The fix is to clean it on a trigger instead of on a crisis. The moment Xcode quits is ideal: the whole folder is regenerable at that point and nothing is using it. A daily clean or a size limit works too, as long as the clean is careful about what Xcode has open.

Dustpan does this from the menu bar

Dustpan shows DerivedData's size in the menu bar and cleans it automatically when Xcode quits, on Product → Clean Build Folder, daily, or past a size limit, with one click or ⌘⇧K for right now. While Xcode is running it keeps anything written in the last minute and anything a running app is using, or leaves open projects alone entirely if you prefer. It is sandboxed, has no network access, and is a modern successor to the long-retired Watchdog for Xcode.

Dustpan on the Mac App Store · $4.99 · macOS 15 or later on Apple silicon