A package dependency of a Swift package.


class Package.Dependency


A package dependency consists of a Git URL to the source of the package, and a requirement for the version of the package.

The Swift Package Manager performs a process called dependency resolution to figure out the exact version of the package dependencies that an app or other Swift package can use. The Package.resolved file records the results of the dependency resolution and lives in the top-level directory of a Swift package. If you add the Swift package as a package dependency to an app for an Apple platform, you can find the Package.resolved file inside your .xcodeproj or .xcworkspace.


Creating a Package Dependency

static func package(url: String, from: Version) -> Package.Dependency

Create a package dependency that uses the version requirement, starting with the given minimum version, going up to the next major version.

static func package(url: String, Range<Version>) -> Package.Dependency

Add a package dependency starting with a specific minimum version, up to but not including a specified maximum version.

static func package(url: String, ClosedRange<Version>) -> Package.Dependency

Add a package dependency starting with a specific minimum version, going up to and including a specific maximum version.

static func package(url: String, Package.Dependency.Requirement) -> Package.Dependency

Add a remote package dependency given a version requirement.

static func package(path: String) -> Package.Dependency

Add a dependency to a local package on the filesystem.

Declaring Requirements

let requirement: Package.Dependency.Requirement

The dependency requirement of the package dependency.

enum Package.Dependency.Requirement

An enum that represents the requirement for a package dependency.

Describing a Package Dependency

let url: String

The Git url of the package dependency.

struct Version

A version according to the semantic versioning specification.

Instance Properties

Instance Methods


Conforms To

See Also

Declaring Package Dependencies

var dependencies: [Package.Dependency]

The list of package dependencies.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software