Developer Disk Cleanup

How to Clear Xcode Derived Data Safely

Learn what Xcode Derived Data contains, when it is safe to delete, and how to clear one project or the entire folder without touching source code

Published August 10, 2026Updated August 12, 2026By Harry
Developer reviewing generated Xcode build data before reclaiming disk space

Yes, you can safely delete Xcode Derived Data. The default folder contains generated build products and indexes that Xcode can create again. Deleting it does not delete your project source code, but the next build and code indexing pass will take longer.

The important part is scope: quit Xcode first and make sure you are deleting ~/Library/Developer/Xcode/DerivedData, not Archives, simulator devices, or a project folder.

Paths and inspection commands verified on macOS 15.7.7 with Xcode 16.2 on August 10, 2026. Xcode menus can move between releases, but the default Derived Data path and the Terminal methods below remain applicable unless you configured a custom build location.

What is Xcode Derived Data?

Xcode uses Derived Data as a workspace for files it generates while building and understanding a project. It commonly includes:

  • compiled products and intermediate build files;
  • the code index used by navigation, search, and completion;
  • logs and other per-project build support data;
  • local Swift package checkouts and related build data for that workspace.

Apple documents the index inside a workspace-specific Derived Data directory, and its Xcode release notes recommend clearing a project's Derived Data as a recovery step for some build problems. In other words, this folder is meant to be reproducible—not the authoritative copy of your source code.

Deleting it can help when:

  • old projects have left several gigabytes of generated data;
  • a build keeps using stale results;
  • code completion or indexing behaves incorrectly;
  • a package or macro build fails after an Xcode update;
  • you need disk space and accept a slower first rebuild.

Do not clear it on a schedule just because it exists. Active projects benefit from incremental build data, so removing a small, healthy folder only trades disk space for build time.

What is safe to delete?

LocationRecommendationWhat happens after deletion
~/Library/Developer/Xcode/DerivedData/ProjectName-*Safe for a project you recognizeThat project rebuilds and reindexes
Everything inside ~/Library/Developer/Xcode/DerivedDataSafe when you need a full resetEvery Xcode project rebuilds and reindexes
~/Library/Developer/Xcode/ArchivesDo not treat as cacheYou may lose archived builds and the matching debug symbols needed for distribution or crash analysis
~/Library/Developer/CoreSimulator/DevicesReview separatelyYou may lose simulator apps, settings, and test data
Your repository or project directoryDo not deleteThis is your actual source code and project configuration

Also check Xcode Settings → Locations before cleanup. If Derived Data is set to Custom, use the location shown there instead of assuming the default path.

Method 1: Remove Derived Data with Finder

This is the clearest method when you want to inspect project folders before removing anything.

  1. Save your work and stop any running build or test.
  2. Open Xcode → Settings → Locations.
  3. Find Derived Data and select the arrow beside its path to reveal the directory in Finder.
  4. Quit Xcode.
  5. Move only the folder for the affected project to Trash. If you want a complete reset, move the contents of the Derived Data directory instead.
  6. Reopen Xcode and build the project again.

Using Trash gives you a short recovery window. Empty it only after confirming that the project opens and rebuilds as expected.

Method 2: Inspect and clear it from Terminal

First confirm the folder and its total size:

du -sh "$HOME/Library/Developer/Xcode/DerivedData"
du -sh "$HOME/Library/Developer/Xcode/DerivedData"/* 2>/dev/null | sort -h

Each project directory normally starts with a readable project name followed by a unique suffix. To inspect it in Finder:

open "$HOME/Library/Developer/Xcode/DerivedData"

To permanently remove one project, replace the example directory name with the exact name from your own output:

rm -rf "$HOME/Library/Developer/Xcode/DerivedData/YourProject-xxxxxxxxxxxxxxxxxxxxxxxxxxxx"

To permanently remove every entry in the default Derived Data folder:

find "$HOME/Library/Developer/Xcode/DerivedData" \
  -mindepth 1 -maxdepth 1 -exec rm -rf {} +

These commands bypass Trash. Read the full path before pressing Return, and do not run the final command if Xcode is building, testing, or indexing.

Method 3: Try Clean Build Folder first

If one project has a build problem but you do not need to remove its index and all other generated workspace data, start with Product → Clean Build Folder in Xcode. Apple also documents this command as a troubleshooting step.

The command-line equivalent for a workspace can look like this:

xcodebuild \
  -workspace YourApp.xcworkspace \
  -scheme YourApp \
  clean

This is narrower than deleting the entire Derived Data directory. It asks the selected build system to clean that project's build products; it is not a general disk cleanup command for every Xcode workspace.

What should you expect after cleanup?

The first build will usually be slower. Xcode needs to rebuild targets, recreate its index, and may need to resolve or fetch package data again. Code completion and jump-to-definition can also be incomplete until indexing catches up.

Your project files, Git history, signing certificates, provisioning profiles, and Xcode Archives are outside the default Derived Data root. They are not affected when you delete only the exact path described above.

If the original build error returns after a clean rebuild, Derived Data was probably not the root cause. Check the first meaningful compiler error, dependency resolution, the selected Xcode version, and project build settings instead of repeatedly clearing caches.

Review Xcode Derived Data with MangoDisk

If you prefer to see the size and exact location before cleaning, MangoDisk Deep Cleanup includes a dedicated Xcode Derived Data rule.

The rule is intentionally narrow: it targets only the default ~/Library/Developer/Xcode/DerivedData root, requires Xcode to be closed, and is not selected by default. It does not include project source, Archives, signing material, simulator devices, or installed simulator runtimes. Scanning happens locally, and you review the result before cleanup. See the MangoDisk safety guide for the full confirmation and cleanup-history workflow.

Frequently asked questions

Can I delete Derived Data while Xcode is open?

Do not delete it during a build, test, or indexing operation. Quit Xcode first so files are not being rewritten while cleanup is in progress.

Will deleting Derived Data fix every Xcode build error?

No. It is useful for stale or inconsistent generated data, but it cannot fix source errors, invalid signing, missing dependencies, or incorrect build settings.

How often should I clear it?

Clear it when you need meaningful disk space or have evidence of stale build data. There is no benefit to removing healthy Derived Data after every build.

Why did the folder come back?

That is expected. Xcode recreates Derived Data as soon as you build or index a project. Cleanup reclaims old generated data; it does not disable future build caching.

Sources

Want to review generated developer files visually before deciding what to remove? Download MangoDisk and run Deep Cleanup locally.

Xcode Derived DataXcode cachemacOSDeveloper disk cleanup
All articles