Created
August 1, 2025 10:41
-
-
Save barbietunnie/640ea7b1bafbfae769216b3f05d0583c to your computer and use it in GitHub Desktop.
Xcode Cleanup Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "=== Xcode Cleanup Script ===" | |
# 1. Clean old iOS DeviceSupport (keep latest 2) | |
echo "Cleaning old iOS DeviceSupport files..." | |
DEVICE_SUPPORT_DIR="$HOME/Library/Developer/Xcode/iOS DeviceSupport" | |
if [ -d "$DEVICE_SUPPORT_DIR" ]; then | |
cd "$DEVICE_SUPPORT_DIR" || exit | |
echo "Keeping latest 2 versions..." | |
ls -t | tail -n +3 | xargs rm -rf | |
else | |
echo "No DeviceSupport folder found." | |
fi | |
# 2. Clear SwiftUI Previews simulator caches | |
echo "Clearing SwiftUI Previews simulator caches..." | |
PREVIEWS_DIR="$HOME/Library/Developer/Xcode/UserData/Previews/Simulator Devices" | |
if [ -d "$PREVIEWS_DIR" ]; then | |
rm -rf "$PREVIEWS_DIR"/* | |
echo "SwiftUI Previews cleared." | |
else | |
echo "No Previews cache found." | |
fi | |
# 3. Optional: Clear DerivedData | |
echo "Clearing DerivedData (build caches)..." | |
DERIVED_DATA_DIR="$HOME/Library/Developer/Xcode/DerivedData" | |
if [ -d "$DERIVED_DATA_DIR" ]; then | |
rm -rf "$DERIVED_DATA_DIR"/* | |
echo "DerivedData cleared." | |
else | |
echo "No DerivedData found." | |
fi | |
echo "✅ Xcode cleanup complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment