Mopup › Guides › Xcode

How to clear Xcode DerivedData, simulators and other Xcode storage

Xcode is one of the biggest users of disk space on a developer's Mac. Most of what it stores can be rebuilt, so it's safe to clear, as long as you know what each folder is for.

What takes the space

These folders are in ~/Library/Developer, except the CocoaPods cache, which is in ~/Library/Caches.

FolderWhat it holdsSafe to delete?
Xcode/DerivedDataBuild products, indexes and logs of every project you've builtYes. The next build of each project starts from scratch.
Xcode/iOS DeviceSupportFiles Xcode copies from each iOS version of the devices you connectYes, for versions you no longer use. Xcode copies them again when you connect a device.
CoreSimulator/DevicesYour simulators, with the apps and data inside themThe ones you don't use. Simulators for iOS versions you've removed can't start anyway.
CoreSimulator/CachesSimulator cachesYes. Simulators rebuild them.
Xcode/UserData/PreviewsSwiftUI preview buildsYes. Previews rebuild the next time you open one.
Xcode/ArchivesBuilds you archived for release, with the symbols for their crash reportsOnly if you'll never re-export those builds or read their crash reports.
CocoaPodsDownloaded podsYes. They download again on the next pod install.

To see how big each one is, without changing anything:

du -sh ~/Library/Developer/*/* 2>/dev/null | sort -h | tail -15

Clear DerivedData

Quit Xcode first, then run:

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

This deletes the build data of every project, for good, and Xcode makes a new, empty folder on its next build. Your source code isn't touched. The next build of each project takes longer while Xcode rebuilds it. To clear only the build products of the project you have open, choose Product › Clean Build Folder in Xcode.

Remove simulators you can't use

xcrun simctl delete unavailable

This deletes the simulators whose iOS version is no longer installed. To remove whole iOS versions you no longer test on, open Xcode › Settings › Components (called Platforms in older Xcode versions), or list them with xcrun simctl runtime list and remove one with xcrun simctl runtime delete followed by its ID.

Remove old device support files

In Finder, choose Go › Go to Folder, type ~/Library/Developer/Xcode/iOS DeviceSupport, and move the folders for iOS versions you no longer test on to the Trash.

Keep the archives you might need

Each archive holds the debug symbols of its build. Without them you can't make sense of crash reports from that release. Delete old archives in Xcode's Organizer (Window › Organizer) once a release no longer matters.

Mopup's Cleanup section on a demo developer Mac: Xcode build data at 28.4 GB, device support files, simulators for iOS versions no longer installed, simulator caches, SwiftUI preview data and the CocoaPods cache ticked, and Archives marked Your call.

Related guides