If you use Xcode, you've probably seen storage disappear fast. One common cause is DerivedData—build intermediates, indexes, and caches that can accumulate to massive sizes.
This guide explains everything about DerivedData cleanup, with safe methods that won't break your development workflow.
What is DerivedData?
DerivedData is Xcode's build workspace, essentially a cache folder that contains all the files Xcode generates during the build process:
- Compiled binaries and object files: Machine code and intermediate compilation results
- Indexes for code completion: Symbol databases that power IntelliSense-like features
- Preprocessed files and metadata: Expanded macros and build configuration data
- Logs from builds and tests: Debug output and error reports
- Module caches: Swift and Objective-C module dependencies
- Asset catalogs: Processed images and resources for different devices
- Test results: Coverage data and test artifacts
It speeds up development by avoiding recompilation of unchanged files, but it can grow to 10-100 GB over time, especially for large projects.
Why does DerivedData grow so large?
Several factors contribute to DerivedData bloat:
- Frequent builds and tests: Each build adds new artifacts, especially with incremental builds
- Large projects: Apps with many source files, assets, or third-party dependencies
- Multiple configurations: Debug, Release, and various device/simulator targets
- Long development cycles: Old build artifacts accumulate over weeks or months
- Multiple projects: Each Xcode project/workspace gets its own DerivedData subfolder
- Swift compilation: Swift generates more intermediate files than Objective-C
For example, a team working on a complex iOS app with multiple targets might see DerivedData exceed 50GB within a few weeks.
Location of DerivedData
By default, DerivedData is stored in:
~/Library/Developer/Xcode/DerivedData
You can change this location in Xcode → Settings → Locations → Derived Data → Custom Location.
The folder structure looks like:
ProjectName-RandomHash/- Each project gets a unique folderBuild/- Compiled binaries and intermediatesIndex/- Code completion databasesLogs/- Build and test logsModuleCache/- Swift/Objective-C modulesSourcePackages/- Swift Package Manager dependencies
Is it safe to delete DerivedData?
Yes, Xcode will rebuild it automatically. However, be aware of these impacts:
- First build is slower: Clean builds take 2-5x longer initially
- Code indexing takes time: Autocomplete and navigation rebuild from scratch
- Custom configurations may need re-setup: Some build settings might reset
- Test results clear: Coverage data and test histories disappear
Your source code, project files, and Git history remain completely untouched.
How to delete DerivedData safely
Method 1: Via Xcode (Recommended for beginners)
This is the safest GUI method:
- Open Xcode
- Go to Xcode → Settings (or Preferences on older versions)
- Navigate to the Locations tab
- Click the small arrow next to Derived Data to open the folder in Finder
- Quit Xcode completely (Cmd+Q)
- In Finder, select all folders in DerivedData and move to Trash
- Empty Trash
Method 2: Terminal (Fast for advanced users)
For quick cleanup via command line:
# Navigate to DerivedData directory
cd ~/Library/Developer/Xcode/DerivedData
# Remove everything (be careful!)
rm -rf *
# Or remove specific projects
rm -rf ProjectName-*
This method is faster but requires Terminal comfort.
Method 3: Selective cleanup (Best for ongoing development)
Instead of deleting everything, target specific projects:
- Open DerivedData folder in Finder
- Sort by Date Modified or Size
- Delete folders for:
- Old/inactive projects
- Projects you haven't worked on recently
- Failed build artifacts
Keep recent folders for active projects to maintain build speed.
Method 4: Xcode Organizer
For a more targeted approach:
- Xcode → Window → Organizer
- Select your project
- Go to the Archives tab
- Delete old archived builds (not the same as DerivedData, but related)
When to clean DerivedData
Clean when:
- Storage is critically low: Need space urgently
- Builds fail mysteriously: Corrupted cache causing issues
- Switching Xcode versions: Different Xcode versions can have cache conflicts
- Before archiving releases: Ensure clean builds for distribution
- Performance issues: Xcode feels sluggish
- After major project changes: Refactoring or dependency updates
Don't clean daily—only when the benefits outweigh the rebuild time.
Troubleshooting DerivedData issues
Xcode still slow after cleanup
- Rebuild indexes: Xcode → Product → Clean Build Folder (Shift+Cmd+K)
- Restart Xcode: Sometimes the IDE needs a fresh start
- Check disk space: Ensure enough free space for rebuilding
Can't delete some files
- Files in use: Quit Xcode and Simulator completely
- Permission issues: Use
sudo rm -rfin Terminal if needed - Locked files: Check for open processes in Activity Monitor
DerivedData keeps growing quickly
- Disable unnecessary indexes: Xcode → Settings → General → Uncheck "Show live issues"
- Clean build regularly: Use Cmd+K in Xcode to clean products
- Archive old projects: Move inactive code to external storage
Missing symbols or autocomplete
- Wait for indexing: Give Xcode time to rebuild indexes (can take 10-30 minutes)
- Clean and rebuild: Product → Clean Build Folder, then build
- Check project settings: Ensure correct paths in Build Settings
Advanced DerivedData management
For power users:
Custom DerivedData location
Move to external drive for space management:
- Create folder on external drive:
/Volumes/External/XcodeDerivedData - Xcode → Settings → Locations → Derived Data → Custom
- Select your custom location
Automated cleanup scripts
Create a bash script for regular cleanup:
#!/bin/bash
# Clean old DerivedData folders (older than 7 days)
find ~/Library/Developer/Xcode/DerivedData -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;
Monitor DerivedData size
Check size regularly:
du -sh ~/Library/Developer/Xcode/DerivedData
Other Xcode storage cleanup tips
Beyond DerivedData:
- Delete unused simulators: Xcode → Window → Devices and Simulators → Simulators tab → Remove old iOS versions
- Clear build logs: Xcode → Window → Organizer → Projects → Delete logs for old projects
- Archive old projects: Move inactive codebases to backup storage
- Clean package caches:
rm -rf ~/Library/Caches/org.swift.swiftpmfor Swift Package Manager - Remove old documentation: Xcode → Settings → Platforms → Remove unused simulator runtimes
Case study: Developer storage recovery
Scenario: iOS developer with 80GB DerivedData from multiple projects.
Cleanup process:
- Identified largest projects using
du -sh */in DerivedData - Deleted folders for completed projects (30GB)
- Kept active project folders
- Cleaned old simulators (10GB)
- Result: 45GB reclaimed, Xcode performance improved
Time investment: 15 minutes cleanup + 20 minutes rebuild time.
FAQ
Will deleting DerivedData delete my code?
No, only build artifacts. Your project stays in the original location.
How long does rebuilding take?
Depends on project size—minutes to hours. Index rebuild is the slowest part.
Can I automate this?
Yes, with scripts or tools. MacRevive can help monitor developer storage.
What's the difference between Clean and Clean Build Folder?
Clean removes build products from DerivedData. Clean Build Folder removes everything for that project.
Does DerivedData include my app data?
No, it contains build artifacts. App data stays in your project directory.
Can I exclude files from DerivedData?
Not directly, but you can customize build settings to reduce what's generated.
For broader Mac cleanup, see our guides on clearing caches and freeing space safely.
Use MacRevive for developer cleanup
MacRevive helps developers:
- Identify DerivedData: Automatically locates and sizes DerivedData folders
- Safe removal: Guides through cleanup without disrupting workflows
- Monitor storage: Alerts when developer artifacts grow large
- Comprehensive cleanup: Handles caches, logs, and build artifacts across tools
MacRevive integrates developer cleanup into your regular maintenance routine.
Download MacRevive and optimize your Mac for development.
Try MacRevive (Free Download)
MacRevive helps you safely reclaim disk space by cleaning caches, logs, and leftovers — without touching your important files.