Is it safe to delete Xcode DerivedData?

Yes, it is safe to delete Xcode DerivedData. It is a cache of build products, indexes and logs that Xcode recreates the next time you build or open a project. Deleting it never touches your source code or settings; the only cost is a slower first build and a few minutes of re-indexing afterwards. Quit Xcode first.

What is DerivedData?

DerivedData lives at ~/Library/Developer/Xcode/DerivedData. Xcode keeps one folder per project there, holding compiled objects and products, the source index used for autocomplete and navigation, build logs, and module caches. Folders for projects you deleted or have not opened in months stay behind until you remove them, which is why DerivedData often grows to many gigabytes.

Check its size:

du -sh ~/Library/Developer/Xcode/DerivedData

How to delete DerivedData

From Terminal

With Xcode closed:

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

From Xcode or Finder

In Xcode, open Settings → Locations and click the arrow next to the Derived Data path to reveal the folder in Finder. Quit Xcode, then move the folders inside it to Trash.

Just one project

Product → Clean Build Folder (⇧⌘K) removes the current project's build products. To clear its index and logs too, delete that project's folder inside DerivedData; its name starts with the project name.

Other Xcode folders you can clear

FolderWhat it holdsSafe to remove?
~/Library/Developer/Xcode/iOS DeviceSupportDebug symbols copied from each iOS version of every device you connectedYes, for iOS versions you no longer debug on. Xcode copies them again when you connect a device.
~/Library/Developer/CoreSimulatorSimulator devices and their app dataRemove unavailable ones with xcrun simctl delete unavailable. Simulator app data is lost.
~/Library/Developer/Xcode/ArchivesArchived builds and their dSYMsOnly for builds you will never need crash reports for. Keep archives of versions still in users' hands.
~/Library/Caches/CocoaPodsDownloaded pod sourcesYes: pod cache clean --all. Pods are downloaded again on the next pod install.

Simulator runtimes themselves (each iOS version you downloaded) can be managed in Xcode → Settings → Components, where you can delete runtimes you no longer test against.

When deleting DerivedData fixes a build

Clearing DerivedData is also a standard fix when Xcode shows stale errors, autocomplete stops working, or a build fails for no reason after switching branches or Xcode versions. A clean index and fresh build products remove whatever was left in an inconsistent state.

Keeping it small

DerivedData grows back as you work, and that is expected: it is what makes incremental builds fast. What is worth removing regularly are the folders for projects you are not working on, along with device support files for old iOS versions. Doing that every month or two keeps Xcode's footprint in check. For the rest of a developer Mac, see how to free up disk space on a developer Mac.

More guides