Skip to content

Mac file guides

How to clear Xcode cache and free up space

By · Updated · 5 min read

Short answer

Quit Xcode, then delete ~/Library/Developer/Xcode/DerivedData, which holds build products Xcode recreates. Next remove simulators for runtimes you no longer have with xcrun simctl delete unavailable, old iOS DeviceSupport folders, and simulator runtimes you don’t test on. Keep Archives for builds you shipped: they hold the dSYMs that symbolicate crash reports.

Where does Xcode use the most space?

This shows how much each takes:

  • DerivedData (~/Library/Developer/Xcode/DerivedData): build products and indexes for every project you’ve opened.
  • Simulator runtimes and devices (~/Library/Developer/CoreSimulator): several gigabytes per iOS version.
  • iOS DeviceSupport (~/Library/Developer/Xcode/iOS DeviceSupport): symbols copied from each device and OS version you’ve run on.
  • Archives (~/Library/Developer/Xcode/Archives): one per build you’ve archived.
  • Caches (~/Library/Caches/com.apple.dt.Xcode): downloaded documentation and package data.
du -sh ~/Library/Developer/Xcode/* ~/Library/Developer/CoreSimulator 2>/dev/null | sort -hr

How do I delete DerivedData?

  1. 1Quit Xcode.
  2. 2Run the command below, or open Xcode › Settings › Locations and click the arrow next to the Derived Data path to find it in Finder.
  3. 3Open your project again. The first build takes longer while Xcode rebuilds.
rm -rf ~/Library/Developer/Xcode/DerivedData

Product › Clean Build Folder (⇧⌘K) clears only the open project’s build folder.

How do I remove old simulators and runtimes?

This deletes simulator devices whose runtime is no longer installed. It can’t be undone, but it removes nothing you can still run:

xcrun simctl delete unavailable

Remove whole runtimes you don’t test on in Xcode › Settings › Components, or list them with xcrun simctl runtime list and delete one by its identifier.

What should I keep?

  • Archives of builds you’ve shipped: their dSYMs symbolicate crash reports from users.
  • DeviceSupport for the OS on devices you still debug on: Xcode copies it again, but that takes minutes.
  • Provisioning profiles and signing certificates, which live elsewhere and are small anyway.

Clearing developer data with Peekaboo

Turn on Show developer features in Peekaboo’s Settings and its developer cleanup lists Xcode build files, caches, device support and archives, simulators and package-manager caches, each with its size and what removing it means. Simulators and runtimes are always marked Check First, and since they can’t go to the Trash they’re only removed once you turn on permanent removal in Settings › Cleanup. Projects shows your repositories with the build and dependency folders you could clear from each.

  1. 1Open the developer cleanup.⇧⌘B
  2. 2Open Projects to clear rebuildable folders repo by repo.⌥⇧⌘B

Questions

Is it safe to delete DerivedData?

Yes. It only holds build products and indexes. Xcode rebuilds it the next time you build, which takes longer the first time.

Why is ~/Library/Developer so big?

Simulator runtimes and devices are usually the largest part, followed by DerivedData and DeviceSupport. Each iOS version you’ve tested on can add several gigabytes.

Does Clean Build Folder clear DerivedData?

Only the open project’s build folder inside it. Other projects’ data and the indexes stay.

Your privacy choices

With your permission, Google Analytics measures visits to this site using cookies. Privacy policy.