An interactive command-line tool to clean Xcode cache files and free up disk space.
Remove gigabytes of Xcode cache files safely and easily with an interactive terminal interface. Perfect for iOS/macOS developers who want to reclaim disk space without risking their projects.
- π― Interactive Checkbox Selection - Choose exactly what to clean
- π¨ Beautiful Terminal UI - Rich colors and formatting
- π Real-time Storage Calculation - See how much space each category uses
- β‘ Progress Tracking - Animated progress bar during cleanup
- π Safety First - Multiple confirmations and color-coded warnings
- π Clear Explanations - Detailed English descriptions for every option
- π Auto-installation - Automatically installs required packages
- πΎ Significant Space Savings - Typically frees 10-100GB
- macOS (any recent version)
- Python 3.7 or later (usually pre-installed on macOS)
- Xcode (to have cache files to clean)
1. Clone the repository:
git clone https://github.com/OxADD1/Python-CLI-Xcode-Cleanup-Tool.git2. Navigate to directory:
cd Python-CLI-Xcode-Cleanup-Tool3. Make executable:
chmod +x xcode_cleanup.py4. Run the tool:
./xcode_cleanup.pyAlternative: Run directly with Python (no chmod needed)
python3 xcode_cleanup.py| Category | Size | Safety | Default | Description |
|---|---|---|---|---|
| Derived Data | 5-50GB | π’ Safe | β | Build artifacts - Xcode will rebuild |
| Unavailable Simulators | Varies | π’ Safe | β | Old simulator instances |
| Device Support | 1-10GB | π’ Safe | β | Old iOS version support files |
| Simulator Caches | 1-5GB | π’ Safe | β | Simulator cache files |
| Archives | 1-20GB | π‘ Caution | β | Old app builds (keep if needed) |
| Device Logs | 100MB-1GB | π’ Safe | β | Debug logs from devices |
| Swift PM Cache | 1-5GB | π’ Safe | β | Downloaded Swift packages |
| Xcode Previews | 500MB-2GB | π’ Safe | β | SwiftUI preview caches |
| System Caches | 1-3GB | π Advanced | β | System-level Xcode caches |
- π’ Safe - Always safe to delete, Xcode will regenerate (selected by default)
- π‘ Caution - Usually safe, but review first (unselected by default)
- π Advanced - For experienced users only (unselected by default)
Simply run the script and follow the interactive prompts:
./xcode_cleanup.pyKeyboard Shortcuts for Selection:
- β/β - Navigate through items
- Space - Toggle individual item on/off
- a - Select/deselect all items at once
- i - Invert selection
- Enter - Confirm selection
-
View Details (Optional)
- Choose whether to see detailed information about all categories
-
Select Categories
- Use keyboard shortcuts above to select items
- Space for individual selection, a for all, i to invert
- Press Enter to confirm
-
Confirm Cleanup
- Review your selections
- Confirm the cleanup operation
-
Watch Progress
- See real-time progress bar
- View each category as it's cleaned
-
View Results
- See what was cleaned
- Check how much space was freed
-
Empty Trash (Optional)
- Choose whether to empty the macOS Trash
Quick Safe Cleanup:
$ ./xcode_cleanup.py
Would you like to see detailed information? (y/N): n
[Keep default selections]
Confirm? (y/N): y
β¨ Cleanup Completed!
Freed: 35.7 GBFull Cleanup with Archives:
$ ./xcode_cleanup.py
Would you like to see detailed information? (y/N): y
[Navigate to Archives and press Space to select]
Confirm? (y/N): y
β¨ Cleanup Completed!
Freed: 52.3 GB1. Check Python Version
python3 --versionShould show Python 3.7 or later. If not installed:
- Download from python.org
- Or install via Homebrew:
brew install python3
2. Download the Tool
Clone the repository:
git clone https://github.com/OxADD1/Python-CLI-Xcode-Cleanup-Tool.gitNavigate to directory:
cd Python-CLI-Xcode-Cleanup-ToolMake executable:
chmod +x xcode_cleanup.py3. Run the Tool
./xcode_cleanup.py4. Install Dependencies
The tool automatically installs required packages on first run.
If auto-installation fails (Homebrew Python users):
pip3 install --user rich questionaryThen run the tool again:
./xcode_cleanup.py"Permission Denied"
chmod +x xcode_cleanup.py"python3: command not found"
- Install Python 3 from python.org
- Or use Homebrew:
brew install python3
"No module named 'rich'"
The script should auto-install, but if it fails:
pip3 install rich questionary"No such file or directory"
Some directories only exist after using Xcode. This is normal - the tool will skip them.
Cleanup didn't free space
- Check Trash - deleted files go there first
- Empty Trash to actually free space
- Some directories might be empty already
- β Your source code is NEVER touched
- β Your Xcode projects remain intact
- β Only cache files are removed
- β Xcode can regenerate everything we delete
- β Multiple confirmations before deletion
Only Xcode cache directories:
~/Library/Developer/Xcode/DerivedData~/Library/Developer/Xcode/iOS DeviceSupport~/Library/Developer/CoreSimulator/Caches~/Library/Developer/Xcode/Archives(optional)- And similar cache locations
- β Your code/projects
- β Xcode application itself
- β App Store downloads
- β Personal files
- β System files
- Operating System: macOS (any recent version)
- Python: 3.7 or later
- Disk Space: ~15KB for the script itself
- Xcode: Installed (to have files to clean)
Automatically installed on first run:
rich>= 13.0.0 - Terminal UIquestionary>= 2.0.0 - Interactive prompts
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Add command-line arguments (
--auto,--safe-only, etc.) - Export results to JSON/CSV
- Scheduled cleanup (cron job setup)
- Dry-run mode (preview without deleting)
- Support for other development tools (Android Studio, etc.)
This project is licensed under the MIT License - see the LICENSE file for details.
Q: Will this delete my Xcode projects?
A: No! Only cache files are deleted. Your projects and source code are never touched.
Q: How much space will I free?
A: Typically 10-100GB, depending on how long you've been using Xcode.
Q: Can I undo the cleanup?
A: Deleted files go to Trash first. Don't empty Trash if you want to restore something.
Q: Is it safe to delete Derived Data?
A: Yes! Xcode will rebuild it when you build your projects. This is the safest category.
Q: Should I delete Archives?
A: Only if you don't need old app builds. These are .xcarchive files used for App Store submissions.
Q: How often should I run this?
A: Monthly or when you're low on disk space. Some developers run it weekly.
Q: Does this work on Linux or Windows?
A: No, it's designed for macOS only as Xcode is macOS-exclusive.
Q: Do I need to install anything?
A: Just Python 3.7+. The tool auto-installs its dependencies.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Built with Rich for beautiful terminal output
- Uses Questionary for interactive prompts
- Inspired by the iOS developer community's need for disk space management
- Lines of Code: ~450
- Dependencies: 2
- File Size: ~15KB
- Typical Space Freed: 10-100GB
- Average Runtime: 1-5 minutes
Made with β€οΈ for iOS/macOS developers
Star β this repo if it helped you free up disk space!