What is org.swift.swiftpm, and is it safe to delete?

The org.swift.swiftpm folder is the shared cache where Swift Package Manager keeps downloaded package repositories, and it is safe to clear because packages download again when a project needs them.

Shiva ChandraMaker of Clean House · · 2 min read
Short answer

org.swift.swiftpm is the global cache where Swift Package Manager keeps cloned package repositories and manifests, shared by all your projects. It is safe to clear. Run swift package purge-cache or delete the folder with Xcode closed, and packages re-download the next time a project resolves.

Path
~/Library/Caches/org.swift.swiftpm
What it is
Shared cache of Swift package repositories and manifests
Typical size
Hundreds of megabytes to a few gigabytes, depending on how many packages you use
Made by
Swift Package Manager (Xcode and the swift command)
Safe to delete?
Safe to clear
Comes back?
Yes, packages download again the next time a project resolves its dependencies

What is in this folder?

Both Xcode and the swift command line use this cache so a package used by several projects is only fetched once. It holds bare clones of package repositories, plus cached manifest results.

Each project also has its own checkouts, in the project or inside DerivedData, so this cache only saves download time. It is not the source of truth for your dependency versions; Package.resolved in your project is.

Is it safe to delete?

Yes. Clearing it costs a re-download and a slower first resolve for each project. It does not change which versions your projects use.

If you work offline, keep it, because a cleared cache cannot be refilled without network access. Package resolve errors such as a stale checkout are also a reason people clear it.

How do I clear it by hand?

  1. Quit Xcode.
  2. Run the SwiftPM command below. It removes the shared cache.
  3. Open your project. Xcode fetches the packages again.
swift package purge-cache
If the command is not available on an older toolchain, delete the folder instead: rm -rf ~/Library/Caches/org.swift.swiftpm with Xcode closed. In Xcode, File, Packages, Reset Package Caches does a similar job for the open project.

How do I stop it growing?

It refills as you add packages. Clear it occasionally, or after removing projects you no longer build.

How Clean House handles it

Clean House recognizes Swift package caches as downloaded Swift packages made by Swift Package Manager, treats them as data that comes back, and explains that in the Why card. Cleared files go to the Trash, so you can put them back from Recently Cleared.

Questions

Is it safe to delete org.swift.swiftpm?

Yes. It is a download cache. Swift Package Manager fetches packages again when a project needs them.

What does swift package purge-cache do?

It removes the shared Swift package cache so packages are fetched fresh the next time they are needed.

Will clearing it change my package versions?

No. Versions are pinned in Package.resolved in each project.

Sources

  1. Swift.org: Swift Package Manager
  2. Apple Developer: Swift packages in Xcode