Xcode can accumulate gigabytes of build files, indexes, downloaded packages, and simulator data. If your Mac is running low on storage—or Xcode is showing stale build results, acting slowly, or failing to compile—clearing the right cache can help. The safest place to start is Derived Data, which Xcode can recreate automatically. Other items, such as simulator content and archives, need more care because deleting them may remove app data or builds you still need.
This guide explains how to clear Xcode cache on a Mac, what each type of cache does, and which files you should avoid deleting. Follow the steps selectively: you usually do not need to remove every Xcode-related file to solve a build or storage problem.
What Does Xcode Cache Store?
Xcode saves temporary and reusable files so it can build projects more quickly. These files can include compiled products, intermediate build data, indexes used for code completion, module information, and downloaded Swift package dependencies. They are generally safe to regenerate, but clearing them can make the next build slower.
“Xcode cache” does not refer to one single folder. Different kinds of data live in different locations, and not all of them are disposable. For example, Derived Data is usually safe to clear, while Archives can contain the only copy of an app build you plan to distribute.
- Derived Data: Project-specific build files, indexes, and other generated data.
- Module cache: Information Xcode uses to avoid rebuilding modules unnecessarily.
- Swift package data: Downloaded package repositories and resolved dependencies.
- Simulator data: Virtual devices, installed apps, and their data.
- Archives: Saved app builds used for distribution or testing.
How to Clear Xcode Derived Data in Xcode
Removing Derived Data is the most common way to clear Xcode cache. It can resolve problems such as stale build results, errors that persist after code changes, or unusually large project build folders. Xcode will recreate the necessary files the next time you build.
- Open Xcode.
- Choose Xcode > Settings from the menu bar. In older Xcode versions, this option may be called Preferences.
- Select the Locations tab.
- Find Derived Data and click the small arrow beside its path to open the folder in Finder.
- Quit Xcode before removing files.
- In the Finder window, move the folder for the affected project to the Trash. To clear all project Derived Data, you can remove the contents of the Derived Data folder instead.
- Reopen Xcode and build your project again.
Removing only the affected project’s folder is a good choice if you are troubleshooting one app. Clearing all Derived Data can free more storage, but it also means Xcode may need to rebuild indexes and products for every project you open.
The default Derived Data location is usually ~/Library/Developer/Xcode/DerivedData. If you changed the location in Xcode settings, use the path shown in the Locations tab rather than assuming the default applies.
Clear Derived Data Using Finder
You can also open the default Derived Data folder directly. In Finder, select Go > Go to Folder, enter ~/Library/Developer/Xcode/DerivedData, and press Return. Quit Xcode first, then delete the folder for the project you want to reset—or remove the contents if you intend to clear all project build data.
Project folders often have names that combine the project name with a unique identifier, so check their contents or use Xcode’s Locations setting to confirm which folder belongs to your project. If you are unsure, move a folder to the Trash rather than immediately emptying it. You can restore it if you discover you removed something you still need.
Clear Xcode Cache From Terminal
If you are comfortable with Terminal, you can remove the default Derived Data directory with a command. First quit Xcode. Then open Terminal and run:
rm -rf ~/Library/Developer/Xcode/DerivedData
This deletes the entire Derived Data folder, not just one project’s files. The command does not send items to the Trash, and the deletion may be difficult to undo. Check the path carefully before pressing Return. If you prefer a more cautious approach, open the folder in Finder and delete only the project-specific folder you intend to clear.
After clearing Derived Data, open Xcode and build again. The first build may take longer because Xcode must compile files and recreate indexes that were removed.
Use Clean Build Folder for Build Problems
If you are troubleshooting a build rather than trying to free a large amount of disk space, try Xcode’s built-in clean command first. Select Product > Clean Build Folder. Depending on your Xcode version and keyboard settings, you may be able to use Shift-Command-K; if that shortcut does not work, use the menu.
Clean Build Folder removes generated build products for the current project and configuration. It is a useful first step when a build seems to be using outdated output. It is less comprehensive than deleting all Derived Data, and it does not remove archives, simulator data, or every package download.
Try cleaning the build folder before deleting broader caches. If the error continues, quit Xcode and remove the project’s Derived Data folder using the steps above. Then reopen the project and build it again.
Clear the Xcode Module Cache
The module cache stores information about modules that Xcode has compiled or imported. A corrupted or outdated module cache can sometimes contribute to confusing build errors, especially after changing Xcode versions or switching branches with substantial dependency changes.
In many cases, clearing the project’s Derived Data is enough because the module cache is stored within or alongside Derived Data. If you are following a specific troubleshooting guide that asks you to remove the module cache, quit Xcode and inspect the Derived Data location for a folder such as ModuleCache.noindex. Remove that cache folder only if needed. Xcode will recreate it when required.
Avoid deleting unfamiliar folders from the Library directory just because their names include “Xcode” or “cache.” Use Xcode’s settings to confirm locations, and prefer removing a specific known cache over wiping unrelated developer files.
Clear or Refresh Swift Package Data
Swift Package Manager downloads and stores dependencies so projects can use them without fetching every package on each build. If a package appears stuck, outdated, or corrupted, first try refreshing package information in Xcode. Open the project and choose File > Packages > Reset Package Caches, if that option is available in your Xcode version. You can also use Resolve Package Versions to make Xcode resolve the dependencies again.
Package cache behavior and menu labels can vary between Xcode releases. Removing package data manually may require Xcode to download dependencies again, and it can disrupt work if you are offline. Before deleting anything, make sure your project’s package configuration is intact and that you have network access to the required repositories.
For command-line builds, you can ask Xcode to resolve a project’s package dependencies with:
xcodebuild -resolvePackageDependencies
Run the command from the project directory or provide the appropriate project or workspace option for your setup. If the issue affects only one package, updating or resolving that dependency is usually preferable to deleting every package-related folder on the Mac.
Manage Simulator Data Carefully
iOS and other Apple-platform simulators can take up substantial disk space. However, simulator data is not the same as ordinary build cache. A simulator may contain installed apps, saved settings, and test data. Erasing it can remove that information, so do not treat the simulator folder as a harmless cache.
To remove a simulator you no longer use, open Xcode and choose Window > Devices and Simulators. Select the Simulators tab and remove devices you no longer need, if the controls are available in your Xcode version. You can also use Simulator’s options to erase a device’s content and settings, but this resets its data. Check that you do not need anything stored in that virtual device before doing so.
If Xcode lists simulators for runtimes you no longer need, review the installed platforms in Xcode settings and remove unused components through the supported interface. Avoid manually deleting CoreSimulator folders unless you understand exactly what will be removed.
Do Not Confuse Archives With Cache
Xcode archives are saved builds, not disposable cache. They may contain the app archive and related information needed to upload or distribute a release. The default location is commonly ~/Library/Developer/Xcode/Archives.
To review archives, open Xcode’s Organizer window and inspect the builds you have saved. Delete an archive only after confirming you no longer need it for distribution, debugging, or reproducing an earlier release. If you are trying to free storage, archives may be large, but removing them can eliminate important build records.
Similarly, folders for device support files may be used when debugging on physical devices. Do not remove them as a first troubleshooting step. Xcode may download or recreate some files, but doing so can take time and may require a compatible device or network connection.
What to Expect After Clearing Xcode Cache
After you clear Derived Data or another cache, the next build may be slower than usual. Xcode has to compile code again, rebuild indexes, or download dependencies that are no longer available locally. Subsequent builds should return to their normal speed as Xcode recreates reusable files.
If the original problem remains, the cause may not be a cache. Check the build error, confirm that the selected scheme and destination are correct, verify package versions, and make sure you are using a compatible Xcode and SDK version. Restarting Xcode or the Mac can also help with temporary issues, but repeatedly deleting every developer folder is unlikely to fix a configuration or code problem.
How to Prevent Xcode Cache From Using Too Much Space
Some growth is normal: each project and build configuration can produce generated files, and simulators and downloaded platforms add more data. A few habits can make storage easier to manage without disrupting your work.
- Remove old project Derived Data when you no longer work on those projects.
- Delete unused simulator devices or runtimes through Xcode’s supported controls.
- Review old archives in Organizer before removing any saved builds.
- Keep enough free disk space for Xcode to compile projects and download dependencies.
- Use Clean Build Folder for a targeted build reset before clearing broader data.
- Check the actual folder size in Finder before deleting files; a folder name alone does not show how much space it uses.
Do not schedule a script to erase all Xcode data automatically unless you have tested it and understand its effects. A broad cleanup can remove useful simulator state, package downloads, or archives along with temporary build files.
Conclusion
To clear Xcode cache safely, start with the project’s Derived Data folder or use Product > Clean Build Folder for a focused build reset. Use Xcode’s settings to locate Derived Data, quit Xcode before deleting files, and expect the next build to take longer while files are recreated. Treat simulator data, Swift package downloads, device support files, and especially archives as separate items—not as disposable cache. Clearing only what you need is the best way to solve common Xcode build problems while protecting your projects and saved builds.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.