# Is it safe to delete Swift Package Manager’s caches?

Is it safe to delete? · Package caches · Updated 21 November 2026. By Mohit Nippanikar, who makes SiftMac.

## The short answer

- **Yes.** The shared cache in `~/Library/Caches/org.swift.swiftpm` and each package’s `.build` folder are fetched or built again. Keep `~/Library/org.swift.swiftpm`, which holds configuration and security records, not cache.
- **What it costs you:** the next resolve fetches packages again, and the next build starts from scratch.
- **Does it come back?** Yes, at the versions pinned in `Package.resolved`.
- SiftMac’s verdict: Rebuilds

## 1. Where SwiftPM keeps things

- **`~/Library/Caches/org.swift.swiftpm`** is the shared cache used by every package you build with the `swift` tools, including copies of package repositories and cached manifests. `~/.swiftpm/cache` is a link to it.
- **`~/Library/org.swift.swiftpm`** holds SwiftPM’s shared configuration and its security folder, linked from `~/.swiftpm/configuration` and `~/.swiftpm/security`. The security folder keeps fingerprints of package versions you’ve downloaded, so SwiftPM can warn if a version’s contents change later.
- **`.build`** in each package holds that package’s dependency checkouts and build products, made by `swift build`.

Xcode projects that use Swift packages keep their checkouts and build products in the project’s DerivedData folder instead, which clears the way the [DerivedData guide](https://siftmac.com/guides/xcode-deriveddata) describes.

## 2. Where they are

```
~/Library/Caches/org.swift.swiftpm
~/Library/org.swift.swiftpm
~/Projects/MyPackage/.build
```

The `--cache-path`, `--config-path` and `--scratch-path` options point a single command elsewhere; `.build` is the default scratch path.

## 3. How big they get

```
du -sh ~/Library/Caches/org.swift.swiftpm
du -sh ~/Projects/MyPackage/.build
```

The shared cache keeps repository copies for the packages you’ve resolved, so its size follows how many packages you use and how long their Git histories are. A package’s `.build` grows with its dependencies and every configuration you’ve built.

## 4. How to clear them

SwiftPM has one command for each level:

| Command | What it removes |
| --- | --- |
| `swift package clean` | Build artifacts in `.build`; dependency checkouts stay |
| `swift package reset` | The package’s complete cache and build directory |
| `swift package purge-cache` | The global repository cache shared by all packages |

```
cd ~/Projects/MyPackage
swift package purge-cache
swift package reset
```

In Xcode, the File › Packages menu has Reset Package Caches and Resolve Package Versions for the open project.

Leave `~/Library/org.swift.swiftpm` in place. Deleting it frees little and throws away your SwiftPM configuration and the fingerprint records it checks packages against.

## 5. What happens afterwards

- The next `swift build` or `swift package resolve` fetches each dependency again at the versions in `Package.resolved`, so it needs the network and takes longer on a slow connection.
- After `reset`, or deleting `.build`, the next build compiles everything, dependencies included.
- Xcode resolves packages again the next time it opens the project.
- `Package.swift`, `Package.resolved` and your sources aren’t touched.

## Questions

### What’s the difference between swift package clean and reset?

`clean` deletes build artifacts and keeps dependency checkouts, so the next build recompiles without fetching anything. `reset` empties the package’s whole cache and build directory, so the next build fetches dependencies too.

### Is ~/Library/org.swift.swiftpm a cache?

No. It’s SwiftPM’s configuration and security folder. The cache is `~/Library/Caches/org.swift.swiftpm`.

### Will purge-cache change my package versions?

No. `Package.resolved` pins them; purging only means they’re fetched again.

### Does deleting DerivedData clear Swift packages for Xcode projects?

For that project, yes: Xcode keeps its package checkouts in DerivedData and fetches them again when you next open and build the project.

## How SiftMac handles it

Its App caches category lists `~/Library/Caches/org.swift.swiftpm` as Swift packages with a Rebuilds verdict and clears what’s inside, keeping the folder. Under Developer files it lists `.build` folders next to a `Package.swift` in projects unchanged for 1, 3 or 6 months, and Xcode DerivedData for projects you haven’t opened in that time.

Download: https://siftmac.com/SiftMac.dmg (scanning is free, and so is the first 2 GB of cleaning).

## Sources

- [Swift Package Manager docs: swift package purge-cache](https://docs.swift.org/latest/documentation/packagemanagerdocs/packagepurgecache)
- [Swift Package Manager docs: swift package reset](https://docs.swift.org/latest/documentation/packagemanagerdocs/packagereset)
- [Swift Package Manager docs: swift package clean](https://docs.swift.org/latest/documentation/packagemanagerdocs/packageclean)
- [Swift Package Manager docs: Package Security (fingerprints)](https://docs.swift.org/latest/documentation/packagemanagerdocs/packagesecurity)
- [Apple: Adding package dependencies to your app](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app)

## Related

- [Is it safe to delete CocoaPods’ cache and a project’s Pods folder?](https://siftmac.com/safe-to-delete/cocoapods-cache)
- [Is it safe to delete Xcode’s DerivedData folder?](https://siftmac.com/guides/xcode-deriveddata)
- [Is it safe to delete Xcode simulators and CoreSimulator?](https://siftmac.com/safe-to-delete/xcode-simulators)
- [What fills an iOS or Mac developer’s Mac, and what Xcode makes again](https://siftmac.com/for/ios-developers)
- [Xcode DerivedData, node_modules and Docker: what’s safe to delete on a developer’s Mac](https://siftmac.com/guides/developer-files-on-mac)

Canonical: https://siftmac.com/safe-to-delete/swift-package-manager-cache
