ElfClean

ElfClean / Guides

How to clear Xcode DerivedData, simulators and device support

Xcode is one of the biggest users of space on a developer's Mac, and most of it is in ~/Library/Developer. Some of it rebuilds itself and can go any time; some of it is your only copy. Here's which is which.

FolderWhat it isSafe to remove?
DerivedDataBuild products, indexes and logs for every project you've built.Yes. The next build starts from scratch and takes longer.
Device supportDebug symbols copied from each iPhone, Watch or other device you connected, per system version.Old versions, yes. Xcode copies them again when you debug on that device.
Simulator devicesEach simulated device, with the apps and data on it.Careful: the device and its data are gone. Xcode can make a new, empty one.
Simulator cachesCaches the simulator service rebuilds.Yes.
ArchivesBuilds you archived to submit, with their debug symbols.Keep the ones you've shipped: without them you can't read those versions' crash reports.
SwiftUI previewsThe devices previews run on.Yes. Made again the next time you preview.

DerivedData

Quit Xcode first, then:

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

Each project has its own folder in there, named after the project with a hash, so you can also remove just the ones for projects you no longer build. Projects that set a custom DerivedData location in their workspace settings or build scripts keep it inside the project instead.

Device support

du -sh ~/Library/Developer/Xcode/*DeviceSupport/*

There's one folder per platform (iOS DeviceSupport, watchOS DeviceSupport and so on) and one subfolder per system version. Versions you no longer have on any device can go. If you connect a device with that version again, Xcode copies the symbols back, which can take several minutes.

Simulators

List devices and delete the ones Xcode can no longer run:

xcrun simctl list devices
xcrun simctl delete unavailable

Simulator runtimes, which are several gigabytes each, are managed separately:

xcrun simctl runtime list
xcrun simctl runtime delete <runtime-id>

Or open Xcode's Settings, choose Components, and remove the platforms you don't develop for. Before deleting a device, remember it holds whatever apps and test data you put on it.

Archives

Archives live in ~/Library/Developer/Xcode/Archives, one folder per day. In Xcode's Organizer you can see which are which. Each holds the debug symbols (dSYMs) for that build; without them, crash reports from that release can't be read, and rebuilding the same commit later doesn't give identical symbols. Delete archives of builds that never shipped; keep, or back up, the ones that did.

How ElfClean does it

ElfClean finds DerivedData, archives, device support unused for 90 days, simulator caches and devices (with the runtime each uses), preview devices and Xcode's own caches. It also finds DerivedData kept inside projects you haven't touched for a while, plus the package caches for Swift packages, CocoaPods and Homebrew.

DerivedData and caches are marked as rebuilding themselves. Archives and simulator devices are marked as possibly your only copy, so they wait for your decision. Everything goes to the Trash, and History can put it back.

More guides