Clearing Swift Package Manager Cache in Xcode

3 min readMar 18, 2024


Clearing Swift Package Manager Cache in Xcode

When working with Swift Package Manager, it’s common to encounter situations where we need to clear the cache because Xcode doesn’t refresh directories with the latest versions of files. This often happens when our dependencies are packages pointed to using a git branch, for example:

Adding a dependency in our manifest:

url: "",

Or directly in an Xcode project:

Xcode project package dependencies panel

To resolve cache-related issues, we have two options:

  • Use the Reset Package Caches option in Xcode.
  • Manually delete the entire cache on our machine.

Zeroth Option

Before explaining the two options mentioned above, it’s worth noting the zeroth option. This involves closing and reopening Xcode. Many times, this solves the problem, so it’s worth a try.

GIF that says: “Have you tried turning it off and on again?”

Using the Reset Packages Caches Option in Xcode

This is achieved by right-clicking on Xcode and selecting the Reset Packages Caches option:

Resetting the cache from Xcode

Manually Deleting the Entire Cache on Our Machine

This usually works, but not always. When we see that it doesn’t work, we can use the following script:

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

These two directories store data about our packages to help us get cached versions and speed up the compilation process. However, if the cached version is not the one we need, we may face a situation where Xcode never updates the files properly.

It’s important to note that running these scripts deletes all cached data. So, if we have other packages in other projects that were working correctly, this might cause the next time we open the project to be a bit slower because Swift Package Manager will need to resolve dependencies from scratch.

A Third Option

A third solution, if the nature of the project allows, is to start using versioning in our packages and establish a strategy where we generate new versions frequently. This is more related to how the team decides to work.


Clearing the cache can also help resolve other issues related to security credential failures without apparent reason or conflicts in dependency resolution that don’t make sense.

If you want to read the Spanish version of this article, you can find it here:




Stay up-to-date in the world of mobile applications with our specialised blog.