Essential Shortcuts to Clean Xcode Caches
Clear build folders and simulator caches with these quick commands to keep Xcode snappy.
Xcode occasionally bogs down due to leftover build files, preview data, or outdated simulator caches. If you’re dealing with sluggish performance, failing builds, here are a few terminal shortcuts to clean house fast.
🔧 Quick Terminal Commands
Remove simulator cache:
1
rm -rf ~/Library/Developer/CoreSimulator/Caches
Fix SwiftUI preview glitches:
1
rm -rf ~/Library/Developer/Xcode/UserData/Previews
Free up storage from old archives:
1
rm -rf ~/Library/Developer/Xcode/Archives
Remove old compiled product files:
1
rm -rf ~/Library/Developer/Xcode/Products
Fix Swift Package Manager dependency issues:
1
rm -rf ~/Library/Caches/org.swift.swiftpm
⏳ When to Run These?
- SwiftUI previews fail to load or crash
- Simulator feels slow or stuck
- Builds fail for no clear reason
- You’re switching Xcode versions
- Storage is filling up fast
- SPM packages refuse to resolve
🚀 Pro Tip
Bundle these into a shell script or alias for quick cleanup:
1
2
3
4
5
alias cleanXcodeCache='rm -rf ~/Library/Developer/CoreSimulator/Caches && \
rm -rf ~/Library/Developer/Xcode/UserData/Previews && \
rm -rf ~/Library/Developer/Xcode/Archives && \
rm -rf ~/Library/Developer/Xcode/Products && \
rm -rf ~/Library/Caches/org.swift.swiftpm'
Then just run:
1
cleanXcodeCache
Keeping your Xcode environment clean can save you hours of frustration. Use these shortcuts regularly to stay productive.
☕ Support My Work
If you found this post helpful and want to support more content like this, you can buy me a coffee!
Your support helps me continue creating useful articles and tips for fellow developers. Thank you! 🙏