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:
~/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
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:
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:
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:
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:
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:
Erase All Simulator Device Caches
To wipe temporary caches, test data, and user photos inside all active simulators without deleting the runtimes:
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.
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:
- npm & npx cache bloat:
~/.npm/_cacacheholding 10+ GB of stale tarballs. - Gradle & Android Studio caches:
~/.gradle/cachesholding 20+ GB of duplicate dependencies. - DAW Audio Plugin Caches: Pro Tools Avid AAX, Logic AU, and VST2 caches silently consuming 15+ GB.
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:
- 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. - Orphaned Simulator Runtimes: Check
/Library/Developer/CoreSimulator/Profiles/Runtimes/. - npm / Gradle / CocoaPods caches: Use a tool like CacheMelt to inspect all developer toolchains in one place.