Xcode is an invaluable tool for macOS and iOS developers. But over time, it becomes slower and may even start to crash frequently. One sure way to fix it is to clear the Xcode cache. It allows you to not only force the simulator to reload the code from the server and address other app glitches but also free up gigabytes of space — in fact, it can be 100 GB+ of eaten-up storage. So, keep on reading and learn which Xcode caches are safe to delete and how to remove them manually or with Terminal.

clear-xcode-cache-manually

Is it safe to delete Xcode caches?

The short answer is yes, most Xcode caches are safe to delete. Xcode recreates them when needed, although your first build afterward may take longer.

But still, not everything Xcode stores should be treated the same way:

Xcode data

Safe to delete?

What happens next

DerivedData

Yes

Xcode rebuilds it during the next build

Xcode caches

Yes

Xcode recreates them automatically

Compilation cache

Yes

Subsequent builds may initially be slower

Simulator caches

Yes

Simulator recreates them

Old device support files

Yes, with care

Xcode may download them again if needed

Old simulator runtimes

With care

Keep runtimes you still use

Archives

With care

Keep anything needed for crash symbolication

Xcode Previews

Use the dedicated command

Don't manually delete Preview data

Important: Quit Xcode and stop any active builds or test runs before deleting its caches. Removing files during an active build can cause problems with build data and indexes.

What are Xcode caches?

Caches are bits of information an app stores so it can work faster. In the case of Xcode, the app stores different types of temporary development data to speed up builds and other tasks.

These can include DerivedData, build and compilation caches, Simulator caches, and device support files.

Because these files accumulate as you work on different projects and OS versions, they can take up a significant amount of storage.

How to clear Xcode cache 

Now, we’ll show you how to delete Xcode cache. We’ll provide steps for manual and automatic removal so you can choose which one works best for you.

Use a Mac cleaner [automatic Xcode cache removal]

Let’s start with an easy, automatic method to delete cache in Xcode. It is based on a Cleanup feature in CleanMyMac that allows you to clean your iOS Simulator with the click of a couple of buttons. This makes it quick and easy to use, and you won't risk running into problems with the file system.

  1. Get your free CleanMyMac trial.
  2. Go to the Cleanup tab and run a scan.
  3. Click Review All Junk and remove Xcode Junk.

That’s it! Now, let’s proceed with the steps for manual Xcode cache removal.

Remove Xcode cache manually

1. Clean the project build

If you’re trying to fix a problem with one particular project, start here.

  • With the project open in Xcode, choose: Product > Clean Build Folder
  • Or press: Command + Shift + K
  • Clean the project build

This removes build products and intermediate files for the project so Xcode can create them again during the next build.

If only one project is acting up, Clean Build Folder is a good place to start. If you’re trying to reclaim disk space or fix Xcode-wide issues, you may need to delete DerivedData instead.

2. Check how much space Xcode cache takes up

Before deleting anything, it’s a good idea to see which Xcode files are actually using your storage.

Quit Xcode, open Terminal, and run these commands one by one:

du -sh ~/Library/Developer/Xcode/DerivedData

du -sh ~/Library/Caches/com.apple.dt.Xcode

du -sh ~/Library/Developer/Xcode/iOS\ DeviceSupport

du -sh ~/Library/Developer/CoreSimulator/Caches

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

Terminal will show the size of each folder, so you can decide what is worth cleaning instead of deleting everything blindly.

3. Delete Xcode DerivedData

Derived Data is the place for all temporary build info and project indexes. If something’s not working right, it is okay to delete this folder.

Run:

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

Xcode will create new DerivedData the next time you build your projects.

Recent Xcode versions may also store compilation cache data inside DerivedData in .noindex folders. To check how much space these folders use, run:

du -sh ~/Library/Developer/Xcode/DerivedData/*.noindex

You don’t need a separate cleanup step for them if you’re already deleting DerivedData.

4. Delete Xcode cache files

Xcode also stores cache files separately from DerivedData.

To remove them, quit Xcode and run:

rm -rf ~/Library/Caches/com.apple.dt.Xcode

how to clear Xcode cache on Mac

These files are safe to delete, and Xcode will recreate the cache as you use it again.

You may also see Xcode Caches listed in macOS storage settings but find that you can’t remove them there. In that case, deleting the cache through Terminal lets you remove the files directly.

After cleanup, macOS may take some time to recalculate the amount of storage being used, so don’t worry if the old figure doesn’t disappear immediately.

5. Delete old iOS device support files

Xcode can store support files for iOS versions you’ve used for development and debugging. Over time, old versions can build up and use several gigabytes of storage.

First, see what you have:

ls ~/Library/Developer/Xcode/iOS\ DeviceSupport/

Delete only versions you no longer need.

For example, if you have old iOS 16 support files that you’re sure you no longer use, you could remove them with:

rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/16.*

Be more careful here than with DerivedData. Keep support files for iOS versions you actively test or debug against. If Xcode needs deleted support files again, it may have to download or recreate them.

6. Clear Simulator caches

Simulator data can also build up over time.

To clear its cache, run:

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

You can also remove simulator devices that are no longer available:

xcrun simctl delete unavailable

This is especially useful after removing old simulator runtimes or updating Xcode.

If you want to completely reset a specific simulator instead, open Simulator, then choose:

Device > Erase All Content and Settings

This removes the apps, settings, and data stored in that simulated device, so use it only when you actually want a full reset.

7. Clear Xcode Previews

If SwiftUI Previews are causing problems, don’t manually delete their files with rm -rf.

Instead, use:

xcrun simctl --set previews delete all

This clears the Preview-related simulator data using Apple’s own simctl tool.

A safer way to clean developer junk with CleanMyMac CLI

The Terminal commands above work, but they also mean checking several different locations and deciding what you want to remove.

If you regularly use Terminal, there’s another option: CleanMyMac CLI. It can scan for caches and generated files left by Xcode and other developer tools from the command line.

If you don’t already have CleanMyMac CLI, install it with Homebrew:

brew install --cask cleanmymac-cli

Then verify the installation:

cleanmymac --version

To scan specifically for developer-tool junk, run:

cleanmymac clean dev

The command checks caches and generated files from developer tools such as Xcode, Homebrew, npm, Yarn, pnpm, pip, and Docker, along with other supported tools.

It shows you what it found and how much space the files use before cleanup. You can review the results and deselect anything you want to keep before confirming the cleanup.

This gives you a more convenient way to clean developer junk without remembering all the individual file paths each time.

8. Reset Xcode preferences

If clearing caches and build data hasn’t fixed your problem, you can also reset Xcode’s preferences.

Open Terminal and run:

defaults delete com.apple.dt.Xcode

When you next open Xcode, it will create new preferences.

Because this resets your Xcode preferences rather than just removing cache, leave this step until after you’ve tried the less disruptive options above.

    Tip

    While browsing the Library folder and hunting down Xcode cache, you may notice that it takes up a lot of storage. If that is your case, and you want to free up some space, check out this article on why Xcode cache is so big on Mac and how to fix it.



    When you shouldn't delete Xcode files

    Clearing Xcode cache is generally safe, but timing and file type matter.

    Avoid deleting Xcode files in these situations:

    • An active build or test is running. Wait until it finishes and quit Xcode before deleting DerivedData or caches.
    • You still need the device support version. Removing support files for an iOS version you actively debug against may mean Xcode has to restore them.
    • You're using the simulator runtime. Don't remove active runtimes, particularly while tests or CI tasks are running.
    • You need an archive for crash reporting. Be careful when removing old archives, especially if you rely on their dSYM files for symbolication.
    • You want to clear Xcode Previews. Use xcrun simctl --set previews delete all instead of manually removing the Preview folder.

    We also don't recommend digging through /private/var/folders and manually deleting files you think belong to Xcode. It’s easy to remove the wrong files there.

    If your goal is simply to clear project build files, use Product > Clean Build Folder first. For old DerivedData and Xcode caches, use the dedicated paths above.

    Frequently asked questions about clearing Xcode cache

    Can I delete Xcode caches?

    Yes. Xcode's cache files in ~/Library/Caches/com.apple.dt.Xcode are safe to delete when Xcode isn't running. Xcode recreates the files it needs.

    Is it safe to delete DerivedData in Xcode?

    Yes. DerivedData contains generated build data, indexes, and caches rather than your project source files. Xcode rebuilds this data when you build your projects again, although the first build afterward may take longer.

    How do I clear Xcode cache in Terminal?

    For a basic cleanup, quit Xcode and remove DerivedData and Xcode's cache folder:

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

    rm -rf ~/Library/Caches/com.apple.dt.Xcode

    For a more complete cleanup, check the device support and Simulator sections above before deleting anything else.

    Why is Xcode cache so large?

    DerivedData, build files, compilation caches, Simulator data, device support files, and archives can all accumulate as you work on more projects and OS versions.

    If Xcode is using much more storage than expected, check out our guide to why Xcode is so big on Mac and how to reduce its size.

    To sum up 

    If you’re having problems with Xcode and need to clean the project build or clear out its cache, follow the steps above one by one and check whether the problem has been resolved after each step. Start with Clean Build Folder for a single project, and move on to DerivedData, Xcode caches, and other developer files only when necessary. That way, you can fix Xcode issues and reclaim storage without deleting more than you need to.

    Thanks for reading, and stay tuned!