SwiftPM clean vs reset: choose the right cleanup
Clean compiled products when a build artifact is suspect; resolve dependencies when the lockfile or package checkout is the issue. Avoid broad deletion without identifying the failing layer.
Clean compiled products when a build artifact is suspect; resolve dependencies when the lockfile or package checkout is the issue. Avoid broad deletion without identifying the failing layer.
Try these fixes in order
Start at the package root
Confirm Package.swift is in the current directory and save any local changes to the package or editable dependencies.
Clean build output
Run the clean command to remove package build artifacts. It does not repair an inaccessible Git dependency.
swift package cleanResolve packages again
If dependency resolution is the problem, run the resolver and read its first fetch or version error.
swift package resolveEscalate only if needed
SwiftPM also exposes a reset operation that removes build artifacts and resolved checkouts. Check the installed toolchain help and expect a fresh download before using it.
swift package --helpInterpret what you see
A source change is ignored by a standalone package build
What it suggests: Compiled output may be stale.
Next check: Use swift package clean from the package root, then rebuild with the same toolchain.
A dependency URL fails to fetch
What it suggests: Cleaning compiled products does not fix network access.
Next check: Inspect Git authentication and the first fetch error; resolve dependencies again after fixing it.
A reset would redownload everything
What it suggests: Reset is broader than cleaning build output.
Next check: Preserve local edits and check installed SwiftPM help before using it; compare Package.resolved afterward.
Why this happens
- Compiled package output is stale.
- The actual failure is dependency fetch or version resolution.
Still not working?
Keep Package.resolved under review. Re-resolving can change it; inspect the diff and build with the intended toolchain afterward.
Official sources
These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.