How to delete DerivedData on a Mac (and is it safe?)
Quick answer
Yes, it's safe. DerivedData is Xcode's build cache and Xcode recreates it the next time you build, which is just slower once. Quit Xcode, then delete the contents of ~/Library/Developer/Xcode/DerivedData (in Finder: Go › Go to Folder…, or ⇧⌘G). If you moved it, the real location is in Xcode › Settings › Locations.
What DerivedData is
Every project you open in Xcode gets a folder in DerivedData named after the project plus a long random suffix, like MyApp-bqrgssevdjsgexdwtvmureeljasn. Inside are the compiled build products, the code index that powers autocomplete and jump-to-definition, build logs, and the Swift packages the project downloaded. Nothing in it is your source code.
It grows because Xcode never removes the folder of a project you stopped working on. Projects you deleted years ago can still have gigabytes there.
Where it is
By default: ~/Library/Developer/Xcode/DerivedData. Xcode lets you move it, so check Xcode › Settings › Locations: the Derived Data row shows the current path, with an arrow that opens it in Finder.
Three ways to clear it
- Clean Build Folder (one project, build products only). In Xcode, Product › Clean Build Folder (⇧⌘K). This removes the current project's build products but keeps its index and logs, and leaves every other project's folder alone.
- Finder (everything). Quit Xcode, press ⇧⌘G in Finder, paste
~/Library/Developer/Xcode/DerivedData, select everything inside and move it to the Trash. Empty the Trash to actually free the space. - Terminal (everything). Quit Xcode, then run:
This deletes right away, without the Trash.rm -rf ~/Library/Developer/Xcode/DerivedData/*
Delete just one project
The folder names don't say which project they belong to, but the info.plist inside usually does:
plutil -p ~/Library/Developer/Xcode/DerivedData/*/info.plist | grep WorkspacePath
That prints the workspace each folder was built from. Folders made only by xcodebuild or Flutter sometimes have no info.plist, and then you're left guessing from the name.
What's inside a project's folder
| Folder | What it is | Safe to delete? |
|---|---|---|
Build | Compiled app, frameworks and intermediate files | Yes, rebuilt on the next build |
Index.noindex | The code index behind autocomplete and search | Yes, Xcode re-indexes in the background |
Logs | Build, test and run logs | Yes |
SourcePackages | Swift packages this project resolved | Yes, downloaded again |
ModuleCache.noindex (shared) | Compiled modules shared by all projects | Yes, but every project rebuilds its modules once |
Before you delete
- Quit Xcode or close the project. Deleting a folder Xcode is writing to can confuse a running build or the indexer.
- Expect one slow build per project afterwards, and a few minutes of indexing.
- The Trash doesn't free space until you empty it.
Questions
Is it safe to delete DerivedData?
Yes. It only holds build products, indexes, logs and downloaded packages, all of which Xcode recreates. The cost is one slower build per project.
Will deleting DerivedData delete my code?
No. Your source code and project files live wherever you saved the project, never in DerivedData.
Does Clean Build Folder delete DerivedData?
Only part of it: Product › Clean Build Folder removes the current project's build products. The index, logs and other projects' folders stay.
Why is DerivedData so big?
Xcode keeps a folder for every project you ever built and never removes the ones you stopped using. Large apps with many Swift packages can take several gigabytes each.
Do I need to quit Xcode first?
It's safest. Deleting the folder of a project Xcode has open can break a build in progress or the indexer until you restart Xcode.