How to delete Xcode DerivedData and other Xcode junk safely

Updated · 3 min read · Works on macOS 14 Sonoma and later

Xcode is one of the biggest consumers of disk space on a developer's Mac. Beyond the app itself, it leaves build products, simulator runtimes and device files all over ~/Library/Developer. Most of it can be deleted and Xcode will quietly rebuild what it needs. Here's what each folder is and how to clear it.

First, see how much Xcode is using

Open Terminal and run:

du -sh ~/Library/Developer/Xcode/* ~/Library/Developer/CoreSimulator 2>/dev/null

This prints the size of each Xcode folder. The usual heavyweights are DerivedData, iOS DeviceSupport and CoreSimulator.

DerivedData — safe to delete

~/Library/Developer/Xcode/DerivedData holds build products, indexes and intermediate files for every project you've opened. It's purely a cache. Deleting it is the classic fix for odd build errors, and it frees space instantly.

Quit Xcode, then run:

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

The next build of each project takes longer while Xcode rebuilds its index. Nothing in your source code is affected.

iOS DeviceSupport — mostly safe

Each time you connect a device running a new iOS version, Xcode copies debug symbols into ~/Library/Developer/Xcode/iOS DeviceSupport (and watchOS DeviceSupport for Apple Watch). Each version is several gigabytes. Delete the folders for iOS versions you no longer test on; Xcode copies them again if you reconnect such a device.

Simulators and simulator runtimes

Simulators for devices and iOS versions you no longer have installed can be removed in one command:

xcrun simctl delete unavailable

Simulator runtimes — the iOS versions themselves — are bigger still. Remove old ones in Xcode › Settings › Components (called Platforms in Xcode 15), or list and delete them from Terminal:

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

Archives — keep what you ship

~/Library/Developer/Xcode/Archives holds every app you've archived for TestFlight or the App Store. Archives contain the debug symbols (dSYMs) you need to read crash reports for that build. Delete old archives only for versions no one uses any more — or open Window › Organizer in Xcode and remove them there.

Device logs and caches

~/Library/Developer/Xcode/iOS Device Logs stores crash and console logs pulled from connected devices, and ~/Library/Caches/com.apple.dt.Xcode holds Xcode's own cache. Both are safe to clear while Xcode is closed.

Swift Package Manager and CocoaPods caches

Package checkouts are cached in ~/Library/Caches/org.swift.swiftpm and, for CocoaPods, ~/Library/Caches/CocoaPods. Clearing them is safe; packages download again on the next resolve.

Clear Xcode junk in one click

SpaceSweep's Xcode Junk category measures and clears DerivedData and device logs, and its Storage Explorer shows how big DeviceSupport and CoreSimulator have grown.

Get SpaceSweep

What to keep

  • Archives for builds that are live — you'll need their dSYMs for crash reports.
  • The simulator runtime you develop against — re-downloading it takes a while.
  • ~/Library/Developer/Xcode/UserData — your key bindings, code snippets and themes.

Questions

Is it safe to delete Xcode DerivedData?

Yes. DerivedData is a cache of build products and indexes. Xcode recreates it the next time you build, so the only cost is a slower first build.

How often should I clear DerivedData?

Whenever you need the space or hit a build error that a clean build doesn't fix. Many developers clear it monthly, or after deleting old projects.

Can I delete the CoreSimulator folder?

Don't delete it by hand. Use xcrun simctl delete unavailable and remove old runtimes in Xcode's settings, so Xcode's simulator records stay consistent.

Find out what's filling your Mac.

SpaceSweep scans your disk for free and shows what's safe to remove.