DEV Community

Cover image for How to Delete Derived Data in Xcode: Complete Guide 2026
Sherry Walker
Sherry Walker

Posted on

How to Delete Derived Data in Xcode: Complete Guide 2026

Your Mac storage drops by 5 to 10 GB after weeks of iOS development. Xcode suddenly throws cryptic build errors on code that compiled yesterday. Both problems trace back to one culprit: corrupted derived data.

Derived data can balloon to massive sizes and cause stubborn compilation failures. This guide shows you exactly how to delete derived data in Xcode using three proven methods, when you should clear it, and how to prevent storage bloat in 2026.

What Is Xcode Derived Data and Why Does It Matter

Derived data is Xcode's storage folder containing all intermediate build files, compiled binaries, and indexing information. Located at ~/Library/Developer/Xcode/DerivedData by default, this directory speeds up compilation by reusing previously built components.

When you build an iOS or macOS project, Xcode generates several file types. Build products include your compiled app executables and frameworks. Index stores power code completion and symbol navigation. Module caches hold precompiled Swift and Objective-C modules shared across projects.

How Derived Data Affects Storage Space

A single project's derived data typically consumes 2 to 10 GB of disk space. The folder grows with each build, accumulating files from multiple projects over time. Developers working on 5+ projects often see their DerivedData folder reach 20 to 50 GB within months.

ModuleCache.noindex stores compiled modules that Xcode shares between projects. This subfolder alone can occupy several gigabytes. Each connected iOS device adds another 2.5 GB of device support files to your Developer folder.

When Derived Data Causes Build Problems

Corrupted derived data triggers mysterious build failures that disappear after cleaning. Your code compiles fine yesterday but breaks today with identical source files. Xcode shows errors about missing files or duplicate symbols that don't exist in your project.

These issues happen when cached build artifacts become outdated or conflict with new code. Swift Package Manager dependencies fail to resolve. Code completion stops working. The indexer runs endlessly without finishing. All symptoms point to corrupted derived data needing deletion.

Method 1: Delete Derived Data Through Xcode Preferences

This approach uses Xcode's built-in preferences to locate and delete derived data. Open Xcode and select Preferences from the Xcode menu or press Cmd + Comma.

Click the Locations tab in the preferences window. Look for the Derived Data section showing the folder path. You'll see a small arrow icon next to the path.

Step-by-Step Deletion Process

Click the arrow button next to the derived data path. Finder opens with the DerivedData folder highlighted. This folder contains subfolders for each project you've built.

Quit Xcode completely before deleting files. This prevents permission errors and file conflicts. Right-click the DerivedData folder and select Move to Trash.

You can delete individual project folders instead of everything. Each folder name includes your project name followed by a random string like MyApp-abcdefghijklmnop. Select only the projects you want to clean.

Completing the Cleanup

Empty your trash after deleting the folder. Large derived data folders take time to delete permanently. Some developers report freeing 100+ GB after cleaning old projects.

Reopen Xcode and build your project. Xcode recreates the DerivedData folder automatically. First builds take longer because Xcode compiles everything from scratch without cached files.

Method 2: Delete Derived Data Using Terminal Commands

Terminal provides the fastest way to clear derived data, especially for developers who regularly clean projects. Open Terminal app from Applications > Utilities or press Cmd + Space and type Terminal.

Run this single command to delete all derived data:

rm -rf ~/Library/Developer/Xcode/DerivedData/*

Creating a Terminal Shortcut

Save time by creating a terminal alias for repeated cleanups. Open your shell configuration file with nano ~/.bash_profile for Bash or nano ~/.zshrc for Zsh (default on macOS Catalina and later).

Add this line to create a custom command:

alias purgeallbuilds='rm -rf ~/Library/Developer/Xcode/DerivedData/*'

Save the file and restart Terminal. Type purgeallbuilds to instantly clear derived data anytime. Many iOS developers use this method daily when switching between projects.

Verifying the Cleanup

Check if deletion succeeded by running ls ~/Library/Developer/Xcode/DerivedData. Empty output confirms successful deletion. You can also check folder size before and after with du -sh ~/Library/Developer/Xcode/DerivedData.

Xcode automatically regenerates necessary files on your next build. No manual intervention needed after deletion.

Method 3: Delete Derived Data from Xcode's Window Menu

Xcode 12 and later versions offer project-specific derived data deletion. Select Window > Projects from the menu bar or press Cmd + Shift + 2.

The Projects window displays all recent projects with their build information. Find your project in the list. A blue dot next to the project name indicates it's currently open.

Deleting Per-Project Derived Data

Close your project before deleting its derived data. Select the project from the list. Look for the Delete button next to the Derived Data path.

Click Delete to remove only that project's derived data. This method preserves cached files for other projects, saving rebuild time on apps you're not currently debugging.

Use this approach when troubleshooting one specific project. Full derived data deletion affects all projects, increasing build times across your entire workspace.

When Should You Delete Derived Data in Xcode

Delete derived data immediately when encountering unexplained build failures. Code that compiled yesterday suddenly shows errors without changes. Xcode reports missing files that exist in your project. These symptoms signal corrupted cache files.

Build Error Scenarios Requiring Cleanup

Swift Package Manager fails to resolve dependencies you already downloaded. The error message mentions package locations or checksum mismatches. Clear derived data to reset package caches.

Code completion stops suggesting methods and properties. Symbol navigation breaks, preventing you from jumping to definitions. The indexer shows perpetual activity without finishing. Delete derived data to rebuild the index store.

Xcode shows duplicate symbol errors for code that definitely isn't duplicated. Build output mentions conflicting architectures or module names. These conflicts stem from stale cached modules.

Preventive Maintenance Schedule

Clear derived data monthly if you work on multiple active projects. Weekly cleanups benefit developers juggling 10+ apps. Your DerivedData folder can reach 50 GB+ within three months of intensive development.

Always delete derived data before major Xcode updates. New Xcode versions sometimes conflict with old cache formats. Clean deletion prevents migration errors.

Consider clearing derived data when your Mac storage drops below 40 GB free. Insufficient disk space causes incomplete SDK installations and simulator corruption. Derived data often represents the largest recoverable storage chunk for developers.

Alternatives to Complete Derived Data Deletion

Clean Build Folder offers a lighter alternative to full derived data deletion. Select Product > Clean Build Folder or press Cmd + Shift + K. This removes build products while preserving indexes and caches.

Selective File Deletion

Navigate to the DerivedData folder and delete only specific subfolders. The ModuleCache.noindex folder stores precompiled modules often causing conflicts. Delete this folder separately to fix module-related errors without losing all build artifacts.

Device support files in ~/Library/Developer/Xcode/iOS DeviceSupport accumulate with each iOS version you test. Each version consumes 2.5 GB. Delete old iOS versions you no longer support to reclaim space without touching derived data.

Changing Derived Data Location

Move derived data to a different drive if storage constraints persist. Go to Xcode > Preferences > Locations. Click the Advanced button next to Derived Data. Select Custom and choose a location on an external drive or separate partition.

Some developers use project-relative locations instead of the default shared folder. This keeps each project's build artifacts isolated but increases total storage usage. Projects can't share cached modules with relative locations.

Impact of Deleting Derived Data on Your Projects

Your source code remains completely untouched when deleting derived data. All project files, assets, and configurations stay intact. Only temporary build artifacts get removed.

First Build After Deletion

Expect longer compilation times on your next build. Xcode compiles every file from scratch without cached intermediates. A project taking 30 seconds to build incrementally might need 3 to 5 minutes for a clean build.

Large projects with extensive dependencies show the biggest time increase. Swift packages redownload and recompile. CocoaPods builds all dependencies fresh. Complex frameworks take longer to process.

Subsequent builds return to normal speed. Xcode rebuilds its cache after the first compilation. Incremental builds only recompile changed files, restoring fast iteration cycles.

What Gets Recreated Automatically

Xcode regenerates all necessary derived data during your next build. Index stores rebuild as you work, powering code completion and navigation. Module caches repopulate when building dependencies. Build products appear in the output folder.

You lose nothing permanent by deleting derived data. Archives for App Store submissions live in ~/Library/Developer/Xcode/Archives, a separate location unaffected by derived data cleanup.

Common Problems After Deleting Derived Data

Xcode sometimes fails to recreate the DerivedData folder after deletion. Force quit Xcode and delete the folder again. Restart your Mac if the issue persists. Check folder permissions with ls -la ~/Library/Developer/Xcode.

Permission Errors and Solutions

Build failures mentioning sandbox violations or file-write-create errors indicate permission problems. These happen when Xcode can't write to the DerivedData location. Run sudo chown -R $(whoami) ~/Library/Developer/Xcode/DerivedData to fix ownership issues.

Some developers encounter "Directory not empty" errors when deleting derived data. Close all Xcode instances completely. Check Activity Monitor for lingering Xcode processes and force quit them. Wait 10 seconds before attempting deletion again.

Swift Package Resolution Failures

Packages fail to resolve after clearing derived data if your network blocks GitHub or Swift Package Index. Xcode needs to redownload package metadata. Check your internet connection and firewall settings.

Package dependency conflicts sometimes emerge after derived data deletion. These existed before but were masked by cached versions. Update your Package.swift version requirements to resolve conflicts properly.

Advanced Storage Management for iOS Developers

Beyond derived data, several other Xcode folders consume significant storage. Simulator runtimes in ~/Library/Developer/CoreSimulator/Devices can reach 20 to 150 GB with multiple iOS versions installed.

Cleaning Simulator Data

List all installed simulators with xcrun simctl list devices. Delete unavailable simulators using xcrun simctl delete unavailable. This removes old device profiles from outdated iOS versions.

Reset specific simulator content without deleting the device. Open Simulator, select Device > Erase All Content and Settings. This clears app data while keeping the simulator installed.

Remove entire simulator runtimes you no longer need. Open Xcode > Settings > Platforms (Components in older versions). Delete iOS versions you don't test against. Each runtime saves 5 to 8 GB.

Archive Management Strategy

Archives in ~/Library/Developer/Xcode/Archives store signed builds for App Store distribution. Keep recent archives for debugging production issues. Delete archives older than your current App Store version.

Each archive contains debug symbols needed for crash report symbolication. Don't delete archives for app versions still in user hands. You'll need the dSYM files to decode crash reports from production.

Automating Derived Data Cleanup

Create a shell script to clean all Xcode storage locations at once. Save this script as clean-xcode.sh:

#!/bin/bash echo "Cleaning Xcode derived data..." rm -rf ~/Library/Developer/Xcode/DerivedData/* echo "Removing unavailable simulators..." xcrun simctl delete unavailable echo "Xcode cleanup complete!"

Running Automated Cleanup

Make the script executable with chmod +x clean-xcode.sh. Run it anytime with ./clean-xcode.sh. Add more cleanup commands for caches or old archives based on your needs.

Schedule automatic cleanups using launchd or third-party apps. Some developers run cleanup scripts weekly to prevent storage bloat. Others trigger cleanups before major app releases or Xcode updates.

Third-Party Cleanup Tools

DevCleaner and similar apps provide graphical interfaces for Xcode storage management. These tools show space usage by category and let you selectively delete different file types. Most offer one-click cleanup for derived data, simulators, and archives together.

Use these tools if you prefer visual feedback over command-line operations. They prevent accidental deletion of important files by separating categories clearly.

Best Practices for Managing Derived Data in 2026

Monitor your DerivedData folder size monthly using Finder or du -sh commands. Set a personal threshold like 30 GB for cleanup. Regular monitoring prevents surprise storage alerts.

Project-Specific Strategies

Use project-relative derived data for mission-critical projects requiring absolute build reproducibility. Configure this in File > Project Settings > Derived Data. Build artifacts stay with the project, making builds more predictable.

Keep shared derived data for typical development workflows. Projects share module caches, speeding up builds when working across multiple apps using the same frameworks.

Clean derived data before submitting bug reports to Apple. Reproduction steps should start from a clean state. This eliminates cache corruption as a confounding variable.

Team Coordination Tips

Add derived data deletion to your team's troubleshooting checklist. New developers often waste hours debugging issues that clear with derived data cleanup. Document the process in your project wiki or onboarding materials.

Establish team conventions for when to clean derived data. After pulling major dependency updates, everyone should clear caches. This prevents "works on my machine" scenarios caused by stale cached modules.

Frequently Asked Questions

Is it safe to delete derived data while Xcode is running?

No, always quit Xcode before deleting derived data. Running Xcode might have files open in the DerivedData folder. Deletion can fail with "Directory not empty" or permission errors. Close Xcode, delete the folder, then restart Xcode.

How long does it take to rebuild derived data?

First builds after deletion take 3 to 10 minutes depending on project size. Small projects with few dependencies rebuild in under 2 minutes. Large apps with 50+ Swift packages or CocoaPods might need 15+ minutes for complete indexing and compilation.

Will I lose my app data on simulators?

No, deleting derived data doesn't affect simulator app data. Your test data, UserDefaults, and app documents remain intact. Derived data only contains build artifacts, not runtime app state. Run xcrun simctl erase all separately if you need to clear simulator data.

Can I delete derived data for just one project?

Yes, navigate to ~/Library/Developer/Xcode/DerivedData and find your project's folder. The folder name includes your project name plus a unique identifier. Delete only that folder to preserve other projects' build caches and speed up their builds.

How often should developers clear derived data?

Clear derived data when build errors appear without code changes or when storage drops critically low. Developers on multiple active projects benefit from monthly cleanups. Those working on 1-2 projects might only need quarterly deletion unless problems occur.

Does deleting derived data affect App Store submissions?

No, archives for App Store distribution live in a separate Archives folder. Deleting derived data never touches your signed builds. You can safely clean derived data without impacting submissions, TestFlight uploads, or ad-hoc distribution builds.

What's the difference between Clean and Clean Build Folder?

Clean (Cmd+K) removes build products from the current scheme. Clean Build Folder (Cmd+Shift+K) deletes the entire Build folder including intermediate files. Neither touches derived data's index or module cache. Full derived data deletion is more thorough than both clean options.

Conclusion

Deleting derived data solves the two biggest pain points for iOS developers: mysterious build failures and storage bloat. The three methods covered here give you flexibility based on your workflow preferences and project needs.

Most developers benefit from using terminal commands with an alias for speed. The key is making derived data cleanup a regular habit, not a panic response to storage alerts.

Clear your derived data this week if it's been over a month. Check your storage usage with Finder or terminal. Explore mobile app development Ohio for professional iOS development services that handle these optimizations as part of their workflow. Your Mac will thank you with faster builds and fewer mysterious errors.

Top comments (0)