[go: up one dir, main page]

0% found this document useful (0 votes)
4 views4 pages

Resolving and Updating Dependencies - Documentation

This document provides guidance on resolving and updating dependencies using the Swift Package Manager. It explains the role of the Package.resolved file in caching dependency versions and the commands used to resolve and update dependencies. Additionally, it highlights the limitations of the Package.resolved file in relation to library dependencies and offers best practices for coordinating versions across projects.

Uploaded by

Murat Tanır
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Resolving and Updating Dependencies - Documentation

This document provides guidance on resolving and updating dependencies using the Swift Package Manager. It explains the role of the Package.resolved file in caching dependency versions and the commands used to resolve and update dependencies. Additionally, it highlights the limitations of the Package.resolved file in relation to library dependencies and offers best practices for coordinating versions across projects.

Uploaded by

Murat Tanır
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Resolv"ng and updat"ng dependenc"es | Documentat"on 23/10/2025 10:39

Documentation Language: Swift

Swift Package Manager / Resolving and updating dependencies

Article

Resolving and updating


dependencies
Coordinate and constrain dependencies for your package.

Overview
The package manager records the result of dependency resolution in a file named
Package.resolved at the top-level of the package. When this file is present and you
are resolving dependencies for the top-level (leaf) package of a dependency tree, the
package manager uses the Package.resolved file as a cache of versions of the
dependencies. The Package.resolved file does not pin dependency versions for
packages used as libraries, or are otherwise included as a dependency for another
Swift project. If the package is being resolved as a dependency from another package,
its own Package.resolved file is ignored during that resolution.

Most SwiftPM commands implicitly invoke dependency resolution before running, and
cancel with an error if dependencies cannot be resolved.

Resolving Dependencies
Run swift package resolve to resolve the dependencies, taking into account the
current version constraints in the Package.swift manifest and a Package
.resolved resolved versions file. For packages with a Package.resolved file, the
resolve command resolves to those versions as long as they are still eligible. If you
want to explicitly use the dependencies written into Package.resolved, use the --

https://docs.sw"ft.org/sw"ftpm/documentat"on/packagemanagerdocs/resolv"ngpackagevers"ons Sayfa 1 / 4
Resolv"ng and updat"ng dependenc"es | Documentat"on 23/10/2025 10:39

force-resolved-versions when invoking swift resolve. For example, to force


the dependencies to align with the versions defined in Package.resolved, use:

swift package resolve --force-resolved-versions

If the resolved version’s file changes (for example, because a teammate shared an
update through source control), the next resolve command attempts to update the
package dependencies to match that file. In most cases, the resolve command
performs no changes unless the Package.swift manifest or Package.resolved
file has changed.

Updating the dependencies


Run swift package update to update a package’s dependencies to the latest eligible
versions, which also updates the Package.resolved file.

Coordinating versions of dependencies for your


package
You can use Package.resolved to coordinate the versions of dependencies it uses
for a leaf Swift project - one that isn’t being used as a dependency. For example, you
can keep a Package.resolved file in source control, or resolve it locally and pass it
to a container image build process, in order to ensure another build uses the same
versions of dependencies.

The Package.resolved only helps to resolve dependencies to the specific versions


it defines for leaf projects. It does not provide any dependency pinning for libraries or
packages that are used as dependencies for other Swift projects. For example, if your
package presents a library and has Package.resolved checked in, those versions
are ignored by the package that depends on your library, and the latest eligible
versions are chosen. For more information on constraining dependency versions, see
Adding dependencies to a Swift package.

If a Package.resolved doesn’t exist, each user or build system separately resolves


dependency versions, only updating when they run swift package update, and new

https://docs.sw"ft.org/sw"ftpm/documentat"on/packagemanagerdocs/resolv"ngpackagevers"ons Sayfa 2 / 4
Resolv"ng and updat"ng dependenc"es | Documentat"on 23/10/2025 10:39

users start with the latest eligible version of each dependency. If the Package
.resolved file does exist, any command that requires dependencies (for example,
swift build or swift run) attempts to resolve the versions of dependencies recorded in
the file.

See Also

Guides
Creating a Swift package
Bundle executable or shareable code into a standalone Swift package.

Setting the Swift tools version


Define the minimum version of the swift compiler required for your package.

Adding dependencies to a Swift package


Use other Swift packages, system libraries, or binary dependencies in your
package.

Creating C language targets


Include C language code as a target in your Swift package.

Using build configurations


Control the build configuration for your app or package.

Packaging based on the version of Swift


Provide a package manifest for a specific version of Swift.

Bundling resources with a Swift package


Add resource files to your Swift package and access them in your code.

Releasing and publishing a Swift package


Share a specific version of your package.

https://docs.sw"ft.org/sw"ftpm/documentat"on/packagemanagerdocs/resolv"ngpackagevers"ons Sayfa 3 / 4
Resolv"ng and updat"ng dependenc"es | Documentat"on 23/10/2025 10:39

Continuous Integration Workflows


Build Swift packages with an existing continuous integration setup and prepare
apps that consume package dependencies within an existing CI pipeline.

Plugins
Extend package manager functionality with build or command plugins.

Module Aliasing
Create aliased names for modules to avoid collisions between targets in your
package or its dependencies.

Using a package registry


Configure and use a package registry for Swift Package Manager.

Package Collections
Learn to create, publish and use Swift package collections.

Using shell completion scripts


Customize your shell to automatically complete swift package commands.

Swift Package Manager as a library


Include Swift Package Manager as a dependency in your Swift package.

https://docs.sw"ft.org/sw"ftpm/documentat"on/packagemanagerdocs/resolv"ngpackagevers"ons Sayfa 4 / 4

You might also like