# Swift

`cooldown` gates Swift packages through `--tool swift` (aliases `spm`, `swiftpm`).

## What it reads

A Swift package is a `Package.swift` with its `Package.resolved`.

## Registry

Publish times come from GitHub Releases.

## How it is driven

`cooldown` runs `swift`, or the program `COOLDOWN_SWIFT` names:

- **`check`:** proves the pins current, as described below.
- **`upgrade` and `fix`:** move each package with `swift package update <identity>`, which
  re-resolves it within `Package.swift`'s version constraints.
- **`--build`:** runs `swift build`.

`swift package update` installs as it pins, so Swift upgrades run one at a time across ecosystems;
see [Several ecosystems at once](https://romnn.github.io/cooldown/docs/tools/#several-ecosystems-at-once).

### How `check` proves the pins current

`check` proves `Package.resolved` current with `swift package resolve --force-resolved-versions`.
It runs in place with its checkouts, caches, fingerprints and temporary files in a scratch
directory, so `.build/` and the package stay as they were. A pin file Swift refuses as out of date
is stale, which `--allow-stale-lock` waives.

## Edge cases

The check fetches every pinned repository, so under `--offline` the lock is `lock_unknown`. The lock
is also `lock_unknown` when:

- no `Package.swift` sits beside it;
- the package has a version-specific manifest or a legacy `.swiftpm/config`;
- a pin is not a versioned GitHub release;
- a pin is one the package no longer reaches;
- Swift fails any other way.
