Skip to content

Instantly share code, notes, and snippets.

@maheshj01
Created June 13, 2026 22:33
Show Gist options
  • Select an option

  • Save maheshj01/d6695948bfffab966924a332995e89dd to your computer and use it in GitHub Desktop.

Select an option

Save maheshj01/d6695948bfffab966924a332995e89dd to your computer and use it in GitHub Desktop.
macOS cleanup System Data
#!/bin/bash
echo "🧹 Starting macOS cleanup..."
# User caches
echo "Removing user caches..."
rm -rf ~/Library/Caches/*
# System caches (requires sudo)
echo "Removing system caches..."
sudo rm -rf /Library/Caches/*
# iPhone/iPad backups
echo "Removing old MobileSync backups..."
rm -rf ~/Library/Application\ Support/MobileSync/Backup/*
# Xcode cleanup
echo "Cleaning Xcode DerivedData..."
rm -rf ~/Library/Developer/Xcode/DerivedData/*
echo "Cleaning Xcode Archives..."
rm -rf ~/Library/Developer/Xcode/Archives/*
echo "Cleaning Xcode Device Support..."
rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/*
# Docker cleanup
if command -v docker >/dev/null 2>&1; then
echo "Cleaning Docker..."
docker system prune -af --volumes
else
echo "Docker not installed, skipping."
fi
# Homebrew cleanup
if command -v brew >/dev/null 2>&1; then
echo "Cleaning Homebrew..."
brew cleanup -s
rm -rf "$(brew --cache)"
else
echo "Homebrew not installed, skipping."
fi
# Remove unavailable simulators
if command -v xcrun >/dev/null 2>&1; then
echo "Removing unavailable iOS simulators..."
xcrun simctl delete unavailable
else
echo "Xcode command line tools not found, skipping."
fi
echo "✅ Cleanup complete."
echo "🔄 Recommended: Restart your Mac and recheck Storage."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment