macOS Developer Storage Guide

How to Safely Clean Xcode DerivedData & iOS Simulators (Without Breaking Builds)

If your Mac’s SSD is constantly reporting "Your disk is almost full" under mysterious System Data, Xcode is likely the hidden culprit holding 30 to 80+ GB hostage. Here is how to safely clear it.

By Elem Debbarma
•
Updated November 2026
•
6 min read

1. Why Xcode Eats Up 50+ GB of System Data

Every time you hit Cmd + B or Cmd + R in Xcode, Apple's compiler generates intermediate build objects, precompiled headers, code-completion index databases, module caches, and symbol tables.

Unlike production binaries, these intermediate artifacts are dumped directly into your home library:

# The primary Xcode build cache directory
~/Library/Developer/Xcode/DerivedData/

# Xcode device archives
~/Library/Developer/Xcode/Archives/

# iOS, iPadOS, and watchOS simulator devices and logs
~/Library/Developer/CoreSimulator/Devices/

# Downloaded system simulator runtimes
/Library/Developer/CoreSimulator/Profiles/Runtimes/

Over a few weeks of active Swift, SwiftUI, or React Native development across multiple branches, DerivedData alone routinely inflates to 25 GB to 75 GB. Because macOS categorizes files inside ~/Library as "System Data" in Storage Settings, most developers have no idea where their SSD capacity disappeared.

2. The Dangerous Trap: Why Blind rm -rf Breaks Builds

Beware the Standard StackOverflow Advice Many online posts tell you to simply paste: rm -rf ~/Library/Developer/Xcode/DerivedData. Deleting the entire directory tree removes the root container, causing subsequent xcodebuild, CocoaPods, or Swift Package Manager tasks to fail with missing directory errors.

Certain build scripts and command-line toolchains assume the DerivedData parent folder exists with proper user permissions. If you delete the folder wholesale, you will often encounter compilation errors such as:

error: unable to create directory '~/Library/Developer/Xcode/DerivedData/...': No such file or directory
fatal error: module cache directory could not be created

To prevent this, you must follow the Non-Destructive Skeleton Pattern: purge the disposable subdirectories inside, but preserve the root container and expected folder hierarchies.

3. Safe Manual Terminal Commands

Here are the exact terminal commands to safely inspect and purge your Xcode caches:

Step 1: Check Current DerivedData Size

Open Terminal and run:

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

This prints the total gigabytes currently occupied.

Step 2: Safely Purge Subfolders (Preserving the Root)

Instead of deleting DerivedData, delete its contents with the wildcard glob:

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

Step 3: Purge Xcode Module Caches & Old Archives

Next, clear Xcode's internal IDE caches and old build archives that you no longer need to upload to TestFlight:

# Clear Xcode user caches
rm -rf ~/Library/Caches/com.apple.dt.Xcode

# (Optional) Delete old build archives if not needed
rm -rf ~/Library/Developer/Xcode/Archives/*

4. Cleaning Old iOS Simulator Runtimes

Every major Xcode update bundles a new iOS Simulator runtime (often 8 to 15 GB per runtime). Over the years, your Mac accumulates orphaned runtimes for older iOS versions (iOS 15, 16, 17) that you no longer test against.

Remove Unavailable Simulators with xcrun simctl

Apple provides a built-in CLI tool to prune simulator devices paired with deleted runtimes:

xcrun simctl delete unavailable

Erase All Simulator Device Caches

To wipe temporary caches, test data, and user photos inside all active simulators without deleting the runtimes:

xcrun simctl erase all
The Native 1-Click Solution

Tired of Memorizing Terminal Paths?

CacheMelt is a 3.1 MB native macOS app built with Swift and SwiftUI. It scans Xcode DerivedData, iOS Simulator runtimes, Android NDKs, npm, Gradle, and DAW audio plugin caches in seconds.

  • Skeleton Recreation: Automatically recreates folder structures so builds never fail.
  • Free Tier Included: Clean up to 3 GB 100% free with no account or email required.
  • Apple Notarized: Verified and signed by Apple Developer ID.
CacheMelt native Mac disk cleaner

5. The Automated 1-Click Way (CacheMelt)

While the terminal commands above work, doing this manually every week is tedious. Worse, developers often also run into:

With CacheMelt, you simply open the app, click Scan, review the exact gigabyte breakdown, and click Clean. Everything is cleaned non-destructively in less than 5 seconds.

6. Frequently Asked Questions

Will deleting DerivedData delete my source code?

No. Your actual source code lives in your project repository folders (e.g., ~/Documents/Projects or ~/WebstormProjects). DerivedData only stores intermediate build outputs that Xcode can reconstruct at any time.

How long will the next build take after cleaning?

Because Xcode has to recompile files and rebuild indices, your very next build will be a "cold build" and may take 30 to 90 seconds longer than usual. Subsequent builds will be just as fast as before.

Why does System Data still show high after deleting DerivedData?

If System Data remains unusually high, check:

  1. Time Machine Local Snapshots: macOS creates local snapshots on your SSD when external backup drives aren't plugged in. Run tmutil listlocalsnapshots / to inspect them.
  2. Orphaned Simulator Runtimes: Check /Library/Developer/CoreSimulator/Profiles/Runtimes/.
  3. npm / Gradle / CocoaPods caches: Use a tool like CacheMelt to inspect all developer toolchains in one place.