Guides · Xcode

Is it safe to delete DerivedData? What you lose and what Xcode rebuilds

Deleting DerivedData is the oldest fix in iOS development, and still one of the biggest disk-space wins. Here is what is actually in it, what the next build costs, and how to clear one project instead of all of them.

Short answerYes. DerivedData holds only what Xcode generated from your project: build output, the code index, logs, test results and checked-out Swift packages. It never holds your source code or settings. Quit Xcode, then delete ~/Library/Developer/Xcode/DerivedData or one project's folder in it. The next build is a full build, Xcode re-indexes, and Swift packages are downloaded again.

What's inside DerivedData

Xcode makes one folder per project or workspace, named after it with a random-looking suffix, such as MyApp-ajhbnxahorylcjehgagzezmiekxo. A typical one contains:

Inside a project's folderWhat it isCost of losing it
BuildCompiled products and intermediate files.A full build next time.
Index.noindex, TextIndexThe index behind code completion, jump to definition and search.Xcode re-indexes after opening the project; completion is patchy until it finishes.
SourcePackagesCheckouts of the project's Swift packages.Packages are resolved and downloaded again (needs a network).
Logs, TestResultsBuild, run and test logs and result bundles.Old logs and test results are gone. Usually fine.
info.plistWhere the project lives (WorkspacePath) and when it was last opened.None; it is recreated.

Next to the project folders sits ModuleCache.noindex, precompiled modules shared by every project. Deleting it makes the next build of every project slower, not just one.

Clean Build Folder vs deleting DerivedData

  • Product › Clean Build Folder (⇧⌘K) removes the build products for the project you have open. The index, package checkouts, logs and every other project's folder stay. Use it for "something is stale" build errors.
  • Deleting the project's DerivedData folder resets that project completely: build, index, packages and logs. Use it when Clean Build Folder doesn't fix a problem, for example a "No such module" error after changing packages, or an index that shows errors for code that builds.
  • Deleting all of DerivedData does that for every project plus the shared module cache. It frees the most space and costs the most time on the next builds.

How to delete it

  1. Quit Xcode. If it is building or indexing while the folder disappears, you can get odd errors until the next clean build.
  2. Check where your DerivedData is. Xcode › Settings › Locations › Derived Data. It is ~/Library/Developer/Xcode/DerivedData unless you changed it; the small arrow next to the path opens it in Finder.
  3. See what's big:
    du -sh ~/Library/Developer/Xcode/DerivedData/* | sort -h
  4. Move one project's folder, or all of them, to the Trash. In Finder, or in Terminal on macOS 15 and later:
    # one project
    trash ~/Library/Developer/Xcode/DerivedData/MyApp-*
    
    # everything
    trash ~/Library/Developer/Xcode/DerivedData/*
  5. Empty the Trash once the project builds again. Until you do, the space isn't free, but you can still put the folder back.

You will see rm -rf ~/Library/Developer/Xcode/DerivedData in most answers. It works, but it deletes for good, and a typo in that path is not something you can take back.

Find folders for projects that no longer exist

DerivedData is never cleaned up when you delete, move or rename a project, or clone the same repository to a second place. Each project's folder has an info.plist that says which project it belongs to, so you can check which ones point at a project that no longer exists:

for d in ~/Library/Developer/Xcode/DerivedData/*/; do
  [ -f "$d/info.plist" ] || continue
  p=$(/usr/libexec/PlistBuddy -c "Print :WorkspacePath" "$d/info.plist" 2>/dev/null) || continue
  [ -e "$p" ] || echo "Project gone: $d ($p)"
done

Every folder it prints belongs to a project that is no longer where it was. Those are the safest gigabytes on your Mac. The shared folders, such as ModuleCache.noindex, have no info.plist, so the loop skips them; so does any project folder that lost its info.plist, which is worth a look by size.

When not to delete it

  • Right before a demo, a release or a deadline. A large project can take many minutes to build from scratch.
  • On a slow or metered connection, if the project has many Swift packages.
  • When your DerivedData location is shared with a CI job or a script that expects it.

Will it come back?

Yes, for every project you open again. DerivedData grows with each project, each copy of a project, and each Xcode version, so clearing it is something to repeat every few weeks rather than once. The projects you stopped working on are the ones worth clearing: their folders never get used again.

DerivedData by project name, not by hash

DevSweep lists each DerivedData folder under its project's name with when it was last used, marks folders whose project no longer exists as Safe, and leaves projects you opened in the last three days unticked. What you pick goes to the Trash, and History can put it back.