BS
BleepingSwift
Published on
5 min read

> How to Free Up Disk Space Used by Xcode

Share:

If you've been developing for Apple platforms for a while, Xcode has probably claimed a surprising chunk of your disk. Between simulator runtimes, device support files, derived data, and archives, it's not unusual to find 50-100GB consumed by Xcode-related files. Here's how to get that space back.

The Quick Wins

Before diving into manual cleanup, Xcode has a built-in storage management tool. Open Xcode, go to Settings > Platforms, and you'll see all your installed simulator runtimes with their sizes. Delete any you don't actively need. iOS 15 simulator taking up 7GB but you only support iOS 17+? Gone.

You can also check Settings > Locations to see where Xcode stores derived data and archives. The "Derived Data" path usually points to ~/Library/Developer/Xcode/DerivedData, and you can click the arrow to open it in Finder and see how much space it's using.

Derived Data

Derived data is where Xcode stores build products, indexes, and logs for your projects. It grows over time and can get massive.

Bash
# Check size
du -sh ~/Library/Developer/Xcode/DerivedData

# Delete everything
rm -rf ~/Library/Developer/Xcode/DerivedData/*

This is safe to delete. Xcode will rebuild what it needs the next time you open a project. The only downside is your first build will be slower since there's no cached data.

If you want to be selective, you can delete derived data for specific projects. Each folder is named after a project with a hash suffix, so you can identify and remove only the ones you're done with.

Device Support Files

Every time you connect a physical device running a new iOS version, Xcode downloads support files for that version. These live in ~/Library/Developer/Xcode/iOS DeviceSupport and can add up quickly.

Bash
# Check size
du -sh ~/Library/Developer/Xcode/iOS\ DeviceSupport

# List versions
ls -la ~/Library/Developer/Xcode/iOS\ DeviceSupport

You'll see folders like 17.4.1 (21E236) for each iOS version you've connected. Delete any versions you no longer need to support. If you connect a device running that version again, Xcode will re-download the files.

The same applies to watchOS, tvOS, and visionOS:

Bash
du -sh ~/Library/Developer/Xcode/watchOS\ DeviceSupport
du -sh ~/Library/Developer/Xcode/tvOS\ DeviceSupport
du -sh ~/Library/Developer/Xcode/visionOS\ DeviceSupport

Simulator Runtimes

Simulator runtimes are the big ones. Each iOS version's simulator runtime is 5-8GB. Check what you have installed:

Bash
xcrun simctl runtime list

To delete a runtime you no longer need:

Bash
xcrun simctl runtime delete iOS-17-0

You can also manage these through Xcode > Settings > Platforms, which shows a cleaner interface with download/delete buttons.

Old Simulator Devices

Over time, you accumulate simulator devices for old runtimes or devices you created for testing. List them:

Bash
xcrun simctl list devices

Delete unavailable devices (ones whose runtime is no longer installed):

Bash
xcrun simctl delete unavailable

Or delete all devices and let Xcode recreate the defaults:

Bash
xcrun simctl delete all

CoreSimulator Caches

The simulator also maintains its own caches and data:

Bash
du -sh ~/Library/Developer/CoreSimulator

This folder contains device data, caches, and logs. You can delete the entire Caches subfolder:

Bash
rm -rf ~/Library/Developer/CoreSimulator/Caches/*

For more aggressive cleanup, you can delete device data for simulators you're not using. Each device has a folder named by UUID. If you've already deleted old devices with simctl delete unavailable, this folder should be reasonably clean.

Archives

When you archive a build for distribution, Xcode stores it in ~/Library/Developer/Xcode/Archives. These can be several hundred MB each.

Bash
du -sh ~/Library/Developer/Xcode/Archives

Open the Organizer in Xcode (Window > Organizer) to see your archives with dates and version numbers. Delete old ones you no longer need. If you use a CI/CD system for releases, you might not need local archives at all.

Swift Package Manager Cache

SPM caches resolved packages:

Bash
du -sh ~/Library/Caches/org.swift.swiftpm

You can safely delete this. Packages will be re-downloaded when you build projects that need them:

Bash
rm -rf ~/Library/Caches/org.swift.swiftpm

Documentation Cache

If you've downloaded documentation for offline viewing:

Bash
du -sh ~/Library/Developer/Shared/Documentation

Delete what you don't need, or clear the whole folder and re-download specific docsets through Xcode > Settings > Components.

The Nuclear Option

If you want to start fresh, you can remove nearly everything and let Xcode rebuild what it needs:

Bash
# Derived data
rm -rf ~/Library/Developer/Xcode/DerivedData

# Device support
rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport
rm -rf ~/Library/Developer/Xcode/watchOS\ DeviceSupport
rm -rf ~/Library/Developer/Xcode/tvOS\ DeviceSupport

# Simulator caches
rm -rf ~/Library/Developer/CoreSimulator/Caches

# SPM cache
rm -rf ~/Library/Caches/org.swift.swiftpm

# Old log files
rm -rf ~/Library/Developer/Xcode/UserData/IDEEditorInteractivityHistory
rm -rf ~/Library/Developer/Xcode/UserData/IB\ Support

Don't delete ~/Library/Developer/Xcode/UserData entirely since it contains your code snippets, key bindings, and other preferences.

Automate It

If you want to run cleanup periodically, here's a script you can save and run when disk space gets tight:

Bash
#!/bin/bash

echo "Cleaning Xcode caches..."

# Derived data
rm -rf ~/Library/Developer/Xcode/DerivedData/*
echo "Cleared derived data"

# Simulator caches
rm -rf ~/Library/Developer/CoreSimulator/Caches/*
echo "Cleared simulator caches"

# SPM cache
rm -rf ~/Library/Caches/org.swift.swiftpm/*
echo "Cleared SPM cache"

# Unavailable simulators
xcrun simctl delete unavailable 2>/dev/null
echo "Deleted unavailable simulators"

echo "Done!"

Save it as clean-xcode.sh, make it executable with chmod +x clean-xcode.sh, and run it when needed.

What Not to Delete

A few things you should leave alone:

The ~/Library/Developer/Xcode/UserData folder contains your preferences, snippets, and key bindings. The ~/Library/Developer/Xcode/Templates folder has any custom file or project templates you've created. And obviously, don't delete the Xcode.app itself from /Applications unless you're planning to reinstall.

Provisioning profiles in ~/Library/MobileDevice/Provisioning Profiles should also stay put. Xcode manages these automatically, and deleting them can cause signing issues.

How Much Can You Recover?

It varies, but on a machine that's been used for iOS development for a year or two, you can often reclaim 20-50GB. The biggest wins are usually old simulator runtimes and device support files for iOS versions you no longer target.

Run du -sh ~/Library/Developer before and after to see your results. Your disk will thank you.

subscribe.sh

// Stay Updated

Get notified when I publish new tutorials on Swift, SwiftUI, and iOS development. No spam, unsubscribe anytime.

>

By subscribing, you agree to our Privacy Policy.