If Xcode is slow, shows stale build errors, or behaves as though it has not noticed your latest code changes, clearing its cache may help. The most common fix is to remove Xcode’s Derived Data, which stores build files, indexes, and other generated information. Xcode recreates these files when you build or open a project again.
You can clear Xcode cache on a Mac using Xcode’s settings, Finder, or Terminal. Before deleting anything, quit Xcode and read the folder descriptions below: some folders contain disposable cache, while others hold archives, downloaded platforms, or simulator data you may want to keep.
What Does Xcode Cache Include?
“Xcode cache” can refer to several different kinds of generated data. The right cleanup depends on the problem you are trying to solve. In most cases, start with Derived Data rather than deleting every Xcode-related folder.
- Derived Data: Build products, project indexes, and intermediate files. Removing it is a common first step for resolving stale builds or indexing problems.
- Module cache: Compiled module information used during builds. It is generally stored within Derived Data and can be regenerated.
- Swift Package Manager data: Downloaded package checkouts and related build data. Removing this may make Xcode download dependencies again.
- Simulator data: Installed apps, settings, and files for simulated devices. This is not just cache; deleting it can remove simulator content.
- Archives: Saved app builds, often used for distribution or App Store submission. These are not cache and should not be deleted unless you no longer need them.
Clearing cache usually does not remove your source code, but it can make the next build or project launch take longer. Xcode may need to reindex the project, rebuild files, or download dependencies.
How to Clear Xcode Derived Data in Settings
The easiest way to find the active Derived Data folder is through Xcode. This is useful if you have changed Xcode’s storage location or are unsure which folder your current version uses.
- Open Xcode.
- Choose Xcode > Settings from the menu bar. In older Xcode versions, this may be called Xcode > Preferences.
- Select the Locations tab.
- Find the Derived Data row and click the small arrow beside its location.
- Quit Xcode, then move the relevant project folder inside Derived Data to the Trash. You can remove the entire Derived Data folder if you want to clear generated data for all projects.
- Empty the Trash only after confirming that you do not need anything you removed.
When you reopen a project, Xcode will create new Derived Data as needed. The first build can take longer than usual because the build products and indexes must be generated again.
How to Clear Xcode Cache with Finder
If you do not want to use Xcode settings, you can open the standard Derived Data location directly in Finder. This path is in your user Library, which macOS hides by default.
- Quit Xcode and any related build tools.
- Open Finder and choose Go > Go to Folder from the menu bar.
- Enter
~/Library/Developer/Xcode/DerivedDataand press Return. - Move the folder for the affected project to the Trash, or remove the contents of Derived Data to reset generated data for all projects.
- Reopen Xcode and build the project again.
Project folders in Derived Data often have names based on the project or workspace, followed by a string of characters. If you only have a problem with one project, removing only its folder is a more targeted option than clearing all Derived Data. If you are not sure which folder belongs to the project, use the location shown in Xcode’s settings.
How to Clear Xcode Cache Using Terminal
Terminal can remove Derived Data quickly, but deletion commands need care. First, quit Xcode. Then open Terminal from Applications > Utilities and use the command that matches the scope of your cleanup.
To remove all standard Derived Data, run:
rm -rf ~/Library/Developer/Xcode/DerivedData/*
To remove Derived Data for one project, open the folder first and identify the correct project-specific directory:
open ~/Library/Developer/Xcode/DerivedData
Then remove only the chosen directory by entering its full path. For example:
rm -rf ~/Library/Developer/Xcode/DerivedData/YourProject-XXXXXXXXXX
Replace the example name with the exact folder name on your Mac. Avoid running a command with an unverified path, and do not add wildcards unless you intend to delete every matching item. If you prefer a reversible step, move the folder to the Trash in Finder instead of using rm -rf.
How to Clear Xcode’s General Cache Folder
Some Xcode-related temporary data may also be stored in the macOS user cache directory. If clearing Derived Data has not fixed a specific issue, you can inspect the Xcode cache folder at:
~/Library/Caches/com.apple.dt.Xcode
To open it in Finder, choose Go > Go to Folder and enter the path. Quit Xcode before removing its contents. Delete only the Xcode cache items you recognize; do not remove the entire ~/Library/Caches directory, since it contains data used by many applications. macOS and Xcode can recreate many cache files, but clearing them may not solve every Xcode problem.
How to Clear Swift Package Manager Cache
If a project uses Swift packages and dependency resolution is failing, you may need to refresh package data rather than clear all Xcode cache. In Xcode, open the project and choose File > Packages > Reset Package Caches. The exact menu wording can vary between Xcode versions.
You can also remove package checkouts stored under a project’s Derived Data folder. Xcode will fetch them again when the project resolves packages. Keep in mind that this requires an internet connection for remote dependencies and can increase the time needed for the next build. Avoid deleting package data as a first step if the issue is unrelated to dependencies.
Should You Delete Simulator Data or Device Support?
Simulator files and iOS device support files can use significant storage, but they are not the same as ordinary build cache. Treat them as optional cleanup, not as the default solution for a build error.
To remove simulator apps and settings, use the Simulator app or Xcode’s device management tools. Erasing a simulator can delete its installed apps and local data. If you need to preserve test data, do not erase it without a backup.
Device support files are associated with iOS versions used for debugging connected devices. Removing older files may free space, but Xcode might need to recreate or download support data when you connect a device running that version of iOS. For platform runtimes and simulator downloads, review Xcode’s platform settings and remove only versions you no longer need.
What You Should Not Delete by Mistake
Before cleaning up, check that you are not removing important development or release files. In particular, do not assume every folder inside ~/Library/Developer/Xcode is disposable.
-
Archives: Commonly stored in
~/Library/Developer/Xcode/Archives. These may contain builds you need for distribution, debugging, or submitting updates. - Project files: Your source code, assets, and project configuration usually live outside the cache folder. Still, confirm the path before deleting anything.
- Simulator content: Simulated devices can contain test accounts, app data, and settings that you may want to retain.
- Downloaded platforms: Removing an iOS or other platform runtime can require a later download before you can build or test for it again.
If you are uncertain about a folder, leave it in place until you have confirmed what it contains. A targeted cleanup is safer than deleting the entire Xcode or Developer directory.
What to Do After Clearing Xcode Cache
Once you have removed the selected cache files, reopen Xcode and open your project. Wait for indexing or package resolution to finish, then build again. A slower first build is expected because Xcode is rebuilding generated files. Subsequent builds should return to their usual speed.
If the original problem remains, try these checks before deleting more data:
- Confirm that you opened the correct project or workspace.
- Check that the selected scheme and build destination are correct.
- Review the build error for a specific missing file, package, signing setting, or SDK issue.
- Restart Xcode or your Mac if a process appears stuck.
- Update Xcode only when your project and macOS version support the update.
How Often Should You Clear Xcode Cache?
You generally do not need to clear Xcode cache on a schedule. Xcode manages generated data during normal development. Clear Derived Data when you have a reason, such as persistent stale build output, a broken index, unusually large storage use, or a problem that continues after checking the project configuration.
It is also normal for Derived Data to grow as you work on multiple projects. Removing it can reclaim disk space, but Xcode will gradually build new cache files again. If disk space is tight, review large archives and unused simulator runtimes separately, taking care not to delete builds or device data you still need.
Conclusion
To clear Xcode cache on a Mac, start by quitting Xcode and removing the affected project’s Derived Data through Xcode > Settings > Locations or Finder. Use Terminal only when you have verified the exact path. Clear Swift Package Manager data or simulator files only when the problem points to those areas, and protect archives and other files you may need. After cleanup, reopen the project and allow Xcode to rebuild its cache.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.