What is Xcode DerivedData?

DerivedData is the folder where Xcode stores build products, indexes, and intermediate compiler output for every project you've opened. It lives at ~/Library/Developer/Xcode/DerivedData, with a separate subfolder per project.

Why does DerivedData get so large?

Every build, every SwiftUI preview render, and every code-index update writes more data into DerivedData. On a Mac used for active iOS or macOS development, it's common to see individual project folders reach several gigabytes, and the whole DerivedData directory climb past 20-50GB after a few months without cleanup - especially with large projects or frequent Swift Package Manager resolution.

Is it safe to delete Xcode DerivedData?

Yes, completely. DerivedData is a build cache, not source code or project data. Xcode regenerates it automatically the next time you build or open a project - you'll just see a longer first build afterward while it re-indexes and recompiles from scratch.

How to clear DerivedData from within Xcode

  1. Quit any running builds
  2. Go to Xcode > Settings (or Preferences on older versions)
  3. Open the Locations tab
  4. Click the arrow next to the Derived Data path to reveal it in Finder
  5. Or, from the Xcode menu bar, hold Option and choose Product > Clean Build Folder for a targeted clean of the current project

How to clear DerivedData manually via Finder or Terminal

With Xcode closed, delete the entire folder:

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

Or in Finder, press Cmd+Shift+G, paste ~/Library/Developer/Xcode/DerivedData, and delete the project folders you don't need cached anymore.

Should I clear all of DerivedData or just one project?

If you're low on space right now, clearing everything is the fastest win. If you only want to fix a specific build issue (like stale caching causing weird SwiftUI preview errors), delete just that project's subfolder - it's named after the project with a random suffix, e.g. MyApp-abcdefg.

Does clearing DerivedData fix Xcode build errors?

Often, yes. Stale indexes and cached build artifacts are a common cause of Xcode showing false errors, failing to find symbols that clearly exist, or SwiftUI previews getting stuck. Clearing DerivedData and rebuilding is one of the most reliable general-purpose fixes developers reach for.

Other Xcode-related storage to check

  • Archives (~/Library/Developer/Xcode/Archives) - old app archives from App Store submissions, safe to remove once uploaded
  • iOS Device Support (~/Library/Developer/Xcode/iOS DeviceSupport) - symbol files for every iOS version you've debugged on a physical device; safe to remove entries for OS versions you no longer test
  • Simulator devices - unused simulators accumulate their own storage; clean up via Xcode > Settings > Platforms or the Simulator app

Once you've cleared the caches, DustByte's Large & Old Files tool can help you spot any of these developer folders again if they creep back up over time.