ThisCalculator

Everyday

How to Audit Mac System Data Before Removing Developer Caches

Updated · Standard formula, shown below

This guide helps you safely identify and remove developer caches on your Mac by first auditing what’s actually taking up space. You’ll learn how to measure cache sizes, distinguish safe-to-delete files from essential ones, and free up storage without breaking your development tools. Before starting, make sure you have admin access and a recent Time Machine backup.

What You’ll Need

  • Admin user account on your Mac
  • Time Machine backup (or any backup of your important projects)
  • Terminal app (found in /Applications/Utilities/)
  • Basic familiarity with the command line

Step-by-Step

  1. Open Terminal – Launch Terminal from the Utilities folder. You’ll use it to run safe, read-only commands first.
  2. Check overall storage usage – Run df -h / to see how much free space you have. Note the “Capacity” and “Used” columns. This gives you a baseline before you delete anything.
  3. List common developer cache locations – Run du -sh ~/Library/Caches ~/Library/Developer/Xcode/DerivedData ~/Library/Developer/CoreSimulator/Caches 2>/dev/null. This shows the total size of each folder. If a folder doesn’t exist, it will be skipped silently.
  4. Drill down into each cache folder – For each folder that exists, run du -sh ~/Library/Caches/* 2>/dev/null | sort -rh | head -20 to see the largest subfolders. This helps you spot what’s eating space.
  5. Inspect Xcode DerivedData – Run du -sh ~/Library/Developer/Xcode/DerivedData/* 2>/dev/null | sort -rh | head -10. These are build artifacts and can be safely deleted, but note which projects they belong to.
  6. Check CoreSimulator caches – If you use iOS simulators, run du -sh ~/Library/Developer/CoreSimulator/Caches/* 2>/dev/null | sort -rh | head -10. These are runtime caches and can be cleared, but simulators will rebuild them.
  7. Look for large files in caches – Use find ~/Library/Caches -type f -size +100M 2>/dev/null to list files over 100 MB. Review the list and note any that you recognize as safe to delete (e.g., old download caches).
  8. Check system-level caches (optional) – Run sudo du -sh /Library/Caches/* 2>/dev/null | sort -rh | head -10. You’ll need admin password. These are system-wide caches; be cautious and only delete ones you’re sure about.
  9. Review your findings – Write down the top 5–10 largest caches and decide which ones are safe to remove. Generally, anything under ~/Library/Caches is safe, but avoid deleting caches for apps you use daily (like browser caches) if you want to keep them fast.
  10. Create a backup of critical cache data – If you’re unsure about a specific cache, copy it to an external drive before deleting. For example: cp -R ~/Library/Developer/Xcode/DerivedData /Volumes/Backup/DerivedDataBackup.
  11. Delete selected caches – Use rm -rf on the folders you’ve decided to remove. For example: rm -rf ~/Library/Developer/Xcode/DerivedData/*. Be precise with the path to avoid accidental deletion.
  12. Empty the Trash – Run rm -rf ~/.Trash/* or empty the Trash from Finder to actually free the space.
  13. Verify space freed – Run df -h / again to confirm the space has been reclaimed.

Common Mistakes

  • Deleting the entire cache folder – Instead of rm -rf ~/Library/Caches, remove only subfolders you’ve audited. Some apps recreate their caches automatically, but others might break if the root folder is missing.
  • Ignoring symlinks – Some cache folders contain symlinks to other locations. Using rm -rf on a symlink deletes the link, not the target, but it can still cause confusion. Check with ls -l before deleting.
  • Deleting caches while apps are running – This can cause crashes or data loss. Quit all applications, especially Xcode and simulators, before clearing their caches.
  • Assuming all caches are safe – Some caches, like those for password managers or authentication tokens, should not be deleted. Always check the folder name and do a quick search if unsure.

Tips

  • Use a visual tool – If you prefer a GUI, use Finder’s “Get Info” on folders to see sizes, but the Terminal commands are faster and more accurate.
  • Automate with a script – Save your audit commands in a shell script to run them quickly next time.
  • Clean regularly – Set a monthly reminder to run the audit. Developer caches can grow quickly, especially with Xcode.
  • Keep DerivedData only for active projects – Xcode rebuilds DerivedData automatically, so you can safely delete it for projects you haven’t opened in months.
  • Use `du` with `-h` and `-s` – These flags make output human-readable and summarize, which is much easier to scan.

Troubleshooting

“Permission denied” errors – If you see this when running du or rm, you may need to use sudo for system caches. For user caches, ensure you’re logged in as the correct user.

Space not freed after deletion – If you deleted files but df shows no change, check if an app is still holding the files open. Restart your Mac and check again. Also, ensure you emptied the Trash.

App misbehaving after cache deletion – If an app crashes or loses settings, it likely needed a specific cache. Restore from your backup if you made one, or simply relaunch the app – many caches regenerate automatically.

Terminal command not found – If du or find are not recognized, your PATH might be broken. Run /usr/bin/du instead, or reset your shell profile.

Accidentally deleted something important – If you deleted a cache that was actually needed (e.g., a database cache), you may need to reinstall the app or restore from Time Machine. This is why the audit step is crucial.

Frequently Asked Questions

Q: Is it safe to delete all caches in ~/Library/Caches?
Generally yes, but some apps store user preferences or temporary session data there. It’s safer to delete subfolders selectively.

Q: How often should I clear developer caches?
Every few months, or when you notice disk space running low. Xcode DerivedData can grow to several GB after heavy use.

Q: Will deleting DerivedData slow down Xcode?
Only the first build after deletion will be slower, as Xcode rebuilds the index. Subsequent builds are back to normal speed.

Q: Can I delete caches in /Library/Caches without sudo?
No, system-wide caches require admin privileges. Use sudo and be extra cautious.

Q: What’s the difference between caches and logs?
Caches store temporary data to speed up processes; logs record events. Logs can also be large, but they’re usually safe to delete via the Console app or rm in ~/Library/Logs.

Q: How do I know which cache belongs to which app?
Folder names usually match the app’s bundle identifier (e.g., com.apple.Safari). You can also open the folder in Finder to see file types.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.