Home/Guides/Xcode filled up my disk: how to clear DerivedData and what else is safe to delete

Xcode filled up my disk: how to clear DerivedData and what else is safe to delete

Updated · airankrush

What this guide covers

When you finish, you will have freed a batch of space and know what can be deleted at any time and what needs a backup first. You need: a working remote desktop connection and basic Terminal skills.

Steps

  1. Look at usage before touching anything

    In Terminal, check overall free space and the size of a few common directories:

    df -h /
    du -sh ~/Library/Developer/* 2>/dev/null

    The Storage page in System Settings also shows usage by category. Finding out where the bulk is works better than deleting by feel.

  2. DerivedData: safe to delete

    According to Xcode Help, derived data includes the project index, logs and build products (including intermediate files). The default location is ~/Library/Developer/Xcode/DerivedData, which you can see and change under Xcode > Settings > Locations.

    All of it can be regenerated. After quitting Xcode, delete the project subdirectories there that you no longer need. The only cost is re-indexing and one full build the next time you open the project.

  3. Archives: confirm the backup before deleting

    Every Archive leaves an archive in the Organizer (Window > Organizer) containing the app itself and its symbol files. They are not cleaned up automatically.

    For archives that have been uploaded and are no longer needed, select and delete them in the Organizer. But the symbol files for versions that are live decide whether you can read crash logs later, so upload them to your own storage before deleting.

  4. Simulator devices and runtimes

    xcrun simctl delete unavailable
    xcrun simctl runtime list

    The first deletes simulators the current Xcode no longer supports. Runtimes are the bulk of the usage: use the second to see which exist, then go to Xcode > Settings > Components and click the info button next to a runtime to delete the ones you do not need, or use xcrun simctl runtime delete.

  5. Dependency manager caches

    pod cache clean --all
    swift package purge-cache
    brew cleanup

    These clear, in turn, the CocoaPods download cache, SwiftPM's global repository cache, and Homebrew's old versions and stale downloads. All three only affect whether dependencies have to be downloaded again at the next install.

  6. Unused Xcode versions and installers

    If a side-by-side older Xcode is no longer needed by any project, move the whole app to the Trash and empty it. Xcode archives and runtime images in the Downloads folder can be deleted once installed. These two items are often bigger than all the caches above put together.

  7. What not to touch on a rented machine

    Clean only development-related directories that you recognize, under your own user directory. Do not use "one-click cleaner" tools that scan and delete system directories, and do not delete entries you do not recognize under the system-level /Library. The platform's management and remote-access components live there, and deleting them may leave the machine unreachable.

    When the disk is close to full, both the system and the remote connection can misbehave, so clean up ahead of time rather than waiting for errors. If there is still not enough room after cleaning, the disk configuration is too small; confirm any upgrade or external storage arrangement with Contact support first.

FAQ

Will deleting DerivedData lose my code?

No. It holds only files generated during builds; your source code is in your project directory. This assumes you have not moved the derived data location inside the project directory and then deleted something else by mistake.

Can I write a scheduled job to clean up automatically?

Yes. Put a scheduled job under LaunchAgents in your own user directory, or add a periodic cleanup job in CI. Clear only directories you know for certain can be rebuilt.

Builds got slower after cleaning. Is that normal?

Yes. Derived data and dependency caches trade space for time, so the first build after clearing them starts from scratch. It recovers after that.

Can an external drive solve the space shortage?

External storage adds room for files, but whether it is possible and how it would be arranged has to be confirmed with support first; do not ship anything on your own. Choosing a disk configuration that fits the project size when you order is less trouble; see the plans page.

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All guides