If you've been doing iOS/macOS development for more than a year, Xcode has been quietly claiming 50-150 GB of your disk without telling you. Here's where all that space went and exactly how to get it back.
I'll cover every major Xcode storage sink — DerivedData, simulators, device support, archives, SPM cache, and module cache — with the exact commands to audit and clean each one. Everything here is safe and reversible.
The quick audit: see your damage in 10 seconds
Run this first to understand the scale:
echo "=== Xcode Storage Audit ===" && \
du -sh ~/Library/Developer/Xcode/DerivedData 2>/dev/null && \
du -sh ~/Library/Developer/CoreSimulator 2>/dev/null && \
du -sh /Library/Developer/CoreSimulator/Images 2>/dev/null && \
du -sh ~/Library/Developer/Xcode/Archives 2>/dev/null && \
du -sh ~/Library/Developer/Xcode/iOS\ DeviceSupport 2>/dev/null && \
du -sh ~/Library/Developer/Xcode/watchOS\ DeviceSupport 2>/dev/null && \
du -sh ~/Library/Developer/Xcode/tvOS\ DeviceSupport 2>/dev/null && \
du -sh ~/Library/Caches/org.swift.swiftpm 2>/dev/null && \
du -sh ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex 2>/dev/null
On my machine after 18 months of active development, the total was over 90 GB. Here's what each one is and what to do about it.
1. DerivedData (typically 20-60 GB)
What it is: Xcode's intermediate build output — compiled objects, indexes, build logs, module caches. Every project gets its own subfolder.
Location: ~/Library/Developer/Xcode/DerivedData/
Is it safe to delete? Yes. Xcode regenerates everything on the next build. The only cost is a full rebuild instead of an incremental one. Your source code, provisioning profiles, and App Store submissions are not affected.
How to clean it
Option A — Delete everything:
rm -rf ~/Library/Developer/Xcode/DerivedData/*
Option B — Delete selectively (keep active projects):
# See each project folder with size and last modified date
ls -lahSt ~/Library/Developer/Xcode/DerivedData/
# Delete only folders older than 30 days
find ~/Library/Developer/Xcode/DerivedData -maxdepth 1 -mtime +30 -exec rm -rf {} +
Option C — From Xcode UI:
Xcode → Settings → Locations → click the arrow next to "Derived Data" to open in Finder. Delete what you don't need.
Pro tip: Cmd+Shift+K in Xcode only cleans the current project's build folder. It doesn't touch other projects' DerivedData.
2. Simulator runtimes (5-8 GB each)
What it is: Full OS images for every iOS/watchOS/tvOS version you've ever downloaded. Each one is 5-8 GB.
Where they live:
- User runtimes:
~/Library/Developer/CoreSimulator/Profiles/Runtimes/ - System images (Xcode 15+):
/Library/Developer/CoreSimulator/Images/
How to clean them
# List all installed runtimes with sizes
xcrun simctl runtime list
# Preview what would be deleted (dry run — deletes nothing)
xcrun simctl runtime delete --notUsedSinceDays 180 --dry-run
# Actually delete runtimes not used in 6 months
xcrun simctl runtime delete --notUsedSinceDays 180
# Nuclear option: delete all unavailable/orphaned simulators
xcrun simctl delete unavailable
Or via Xcode: Settings → Platforms → click the minus button on runtimes you don't need.
Rule of thumb: Keep only the 2-3 most recent iOS versions you actively test against. You can always re-download a runtime if you need it.
3. Device support files (1-5 GB per iOS version)
What it is: Debug symbols generated every time you plug in a physical device running a specific iOS version. These accumulate for every iOS version you've ever connected.
Location: ~/Library/Developer/Xcode/iOS DeviceSupport/
How to clean them
# See all device support folders with sizes
du -sh ~/Library/Developer/Xcode/iOS\ DeviceSupport/* | sort -hr
# Delete support files for iOS versions you no longer target
# Example: delete everything older than iOS 17
ls ~/Library/Developer/Xcode/iOS\ DeviceSupport/ | while read d; do
version=$(echo "$d" | grep -oE '^[0-9]+')
if [ "$version" -lt 17 ] 2>/dev/null; then
echo "Removing: $d"
rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/"$d"
fi
done
Also check watchOS DeviceSupport and tvOS DeviceSupport if you've ever connected an Apple Watch or Apple TV.
4. Xcode archives (2-10 GB per archive)
What it is: .xcarchive bundles from every App Store submission or export you've ever done.
Location: ~/Library/Developer/Xcode/Archives/
How to clean them
From Xcode: Window → Organizer → Archives tab → right-click old archives → Delete.
From Terminal:
# See archive sizes grouped by year
du -sh ~/Library/Developer/Xcode/Archives/*
# Delete archives older than 1 year
find ~/Library/Developer/Xcode/Archives -maxdepth 1 -mtime +365 -exec rm -rf {} +
Keep in mind: You only need archives if you want to upload a build to App Store Connect, generate dSYMs, or re-export an IPA. If the app version is already live and you have dSYMs uploaded, the archive is safe to delete.
5. SPM cache (3-8 GB)
This one is sneaky — Swift Package Manager stores resolved packages in a cache directory that grows silently.
Location: ~/Library/Caches/org.swift.swiftpm/
How to clean it
# Check size
du -sh ~/Library/Caches/org.swift.swiftpm/
# Delete the global cache
rm -rf ~/Library/Caches/org.swift.swiftpm/
# Per-project cleanup
swift package purge-cache
swift package reset
The stale references gotcha: Xcode sometimes caches resolved package versions in DerivedData even after you've updated dependencies. If you see version mismatch issues after updating a package:
- Close Xcode completely
- Delete
~/Library/Caches/org.swift.swiftpm/ - Delete the project's DerivedData folder
- Delete
Package.resolvedfrom your project - Reopen Xcode and let it re-resolve from scratch
Unlike Cargo (cargo cache --autoclean-expensive) or pip (pip cache purge), SPM has no built-in cache size management. It's a genuine gap in the tooling.
6. Module cache
What it is: Precompiled module files shared across all Xcode builds.
Location: ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/
# Check size
du -sh ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/
# Delete it (regenerated automatically)
rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/
This is typically 1-3 GB and gets regenerated on the next build. Safe to delete anytime.
The complete cleanup script
Here's a single script that audits everything, shows you the totals, and lets you decide what to remove:
#!/bin/bash
echo "=== Xcode Disk Space Audit ==="
echo ""
paths=(
"$HOME/Library/Developer/Xcode/DerivedData"
"$HOME/Library/Developer/CoreSimulator"
"/Library/Developer/CoreSimulator/Images"
"$HOME/Library/Developer/Xcode/Archives"
"$HOME/Library/Developer/Xcode/iOS DeviceSupport"
"$HOME/Library/Developer/Xcode/watchOS DeviceSupport"
"$HOME/Library/Developer/Xcode/tvOS DeviceSupport"
"$HOME/Library/Caches/org.swift.swiftpm"
"$HOME/Library/Developer/Xcode/DerivedData/ModuleCache.noindex"
)
total=0
for p in "${paths[@]}"; do
if [ -d "$p" ]; then
size=$(du -sm "$p" 2>/dev/null | cut -f1)
total=$((total + size))
printf "%6s MB %s\n" "$size" "$p"
fi
done
echo ""
echo "Total: $((total / 1024)) GB reclaimable"
echo ""
echo "To clean DerivedData: rm -rf ~/Library/Developer/Xcode/DerivedData/*"
echo "To clean simulators: xcrun simctl runtime delete --notUsedSinceDays 180"
echo "To clean SPM cache: rm -rf ~/Library/Caches/org.swift.swiftpm/"
echo "To clean module cache: rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/"
echo "To clean archives: Open Xcode > Window > Organizer > delete old archives"
echo "To clean device support: Manually delete old iOS versions from ~/Library/Developer/Xcode/iOS DeviceSupport/"
Preventing future bloat
- After every major Xcode update: review simulators (Settings → Platforms) and delete old runtimes
- Monthly: run the audit script above
- After shipping a release: delete the archive if you've already uploaded dSYMs
- Consider a cron job for DerivedData older than 30 days:
# Add to crontab (crontab -e)
0 3 * * 0 find ~/Library/Developer/Xcode/DerivedData -maxdepth 1 -mtime +30 -exec rm -rf {} +
Beyond Xcode
If you also work with Docker, Node.js, Homebrew, Python, or other toolchains, those have their own cache bloat problems. On a multi-toolchain developer Mac, total reclaimable space can easily exceed 100 GB.
Disclosure: I'm building CleanSlateX, a macOS app that automates this audit across 13 dev toolchains and shows you every file before it deletes anything — nothing is removed without your approval. But the terminal commands above cover everything you need for Xcode specifically.
What's your DerivedData damage? Run the audit script and share your number in the comments — I'm curious how bad it gets across different setups.
Top comments (0)