Safeguard
Developer Tools•

Swift package requirements: from, exact, revision or branch?

Which SwiftPM requirement to use and what each means for updates and security: from, upToNextMinor, exact, range, revision and branch compared.

Safeguard Security Team
3 min read

For most Swift dependencies, use the from requirement. It sets a minimum version and allows updates up to the next major release, which the Swift documentation calls the recommended way. Exact, revision and branch freeze or float versions in ways that hurt either security patching or reproducibility.

The options compared

RequirementRange allowedDocumentation guidance
from (up to next major)Minimum version up to the next majorRecommended
up to next minorUp to the next minor versionNarrower window of updates
exactOne versionNot recommended, can cause graph conflicts
rangeFor example 1.2.3 up to but excluding 1.2.6Use for tight control
revisionOne Git commitNot recommended, no updates
branchFollows a branch headFor developing packages together or unversioned packages

Security trade-offs

Ranges let fixes in. A from requirement means a patch release inside the same major version can be picked up when you update. Package.resolved still records the exact version, so builds stay stable until you choose to update.

Exact and revision block fixes. You get no updates. If an advisory is published for that version, you must notice it and edit the manifest. They can also make resolution fail when two packages need different versions of one dependency.

Branch is a moving target. The build can change without a change in your repository. That is hard to review and hard to match to an advisory, since advisories are expressed in versions.

The documentation adds a practical rule: packages that use branch or revision requirements cannot be depended on by packages that use version-based requirements, so you must remove them before publishing a version.

A decision guide

  1. Default to from with the lowest version you tested.
  2. Use exact or a tight range only with a written reason, and review it when the dependency gets an advisory.
  3. Use revision only for a short-term pin to a fix that has no release yet, and plan to move to a tagged version.
  4. Do not use branch in anything you ship.
  5. Commit Package.resolved for apps.

What a scanner can do

Advisory databases for Swift describe affected versions as Git tags that follow semantic versioning, and the package name is a Git URL. A dependency on a branch or revision has no clean version for a scanner to match, so treat those as manual review items.

Quick check

Is exact the safest requirement?

It is the most predictable, but the Swift docs do not recommend it. You will not receive fixes unless you edit the manifest, and it can create conflicts.

Can I depend on a package that tracks a branch from a library?

The docs say packages with branch or revision requirements cannot be depended on by packages with version-based requirements.

Safeguard's SBOM and dependency scanning lists each component with its resolved version, which is where a branch or revision pin stands out. The free scan shows your current inventory.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.