Xcode DerivedData: is it safe to delete?
Intermediate build data created by Xcode; rebuilt on the next build.
- Where it lives
~/Library/Developer/Xcode/DerivedData/*
- Risk
- Low risk. The tool rebuilds it when needed, so SPACE256 preselects it in Review.
- Comes back on its own
- Yes
- If you delete it
- The next build of each project will be slower.
- What SPACE256 does
- Moves it to the Trash after you confirm in Review, so you can put it back.
What it is
DerivedData is Xcode’s scratch space. For every project you open, Xcode creates a folder here with intermediate build files, the products of your last builds, the source index that powers code completion and search, and caches of compiled modules. None of it is your work: it is all produced from your project and can be produced again.
Why it grows
Each project, branch and configuration you build leaves its own data behind, and old folders stay after you stop working on a project. Switching Xcode versions or SDKs adds fresh copies next to the old ones. On a Mac used for development for a year or two, DerivedData often holds folders for projects that no longer exist.
When to clear it
- When you need space and are not in the middle of a build.
- When builds behave oddly after an Xcode update; a clean DerivedData is a common first step.
- Inside Xcode, Product › Clean Build Folder clears the current project’s build products only.
When to keep it
If you are about to build a large project and are short on time, keep it: the first build after clearing recompiles everything and re-indexes the project.
Questions
Will deleting DerivedData break my projects?
No. Your source code, settings and signing are not in DerivedData. Xcode rebuilds what it needs on the next build; that build is just slower.
Why does DerivedData keep coming back?
Every project you open gets its own folder, and every build adds indexes, module caches and products to it. Clearing it is safe, but it grows again as you work.
Should Xcode be closed first?
Yes. SPACE256 waits until Xcode is not running before it offers DerivedData, so nothing is removed while Xcode is writing to it.