Requirement
An enum that represents the requirement for a package dependency.
PackageRequirement.swift:57This declaration was deprecated in SwiftPM 5.6.
enum Requirement
The dependency requirement can be defined as one of three different version requirements:
- A version-based requirement
Decide whether your project accepts updates to a package dependency up to the next major version or up to the next minor version. To be more restrictive, select a specific version range or an exact version. Major versions tend to have more significant changes than minor versions, and may require you to modify your code when they update.
The version rule requires Swift packages to conform to semantic versioning. To learn more about the semantic versioning standard, visit the Semantic Versioning 2.0.0 website.
Selecting the version requirement is the recommended way to add a package dependency. It allows you to create a balance between restricting changes and obtaining improvements and features. - term A branch-based requirement: Select the name of the branch for your package dependency to follow. Use branch-based dependencies when you’re developing multiple packages in tandem or when you don’t want to publish versions of your package dependencies.
Note that packages which use branch-based dependency requirements can’t be added as dependencies to packages that use version-based dependency requirements; you should remove branch-based dependency requirements before publishing a version of your package. - term A commit-based requirement: Select the commit hash for your package dependency to follow.
Choosing this option isn’t recommended, and should be limited to exceptional cases. While pinning your package dependency to a specific commit ensures that the package dependency doesn’t change and your code remains stable, you don’t receive any updates at all. If you worry about the stability of a remote package, consider one of the more restrictive options of the version-based requirement.
Note that packages which use commit-based dependency requirements can’t be added as dependencies to packages that use version-based dependency requirements; you should remove commit-based dependency requirements before publishing a version of your package.
Cases
Show obsolete interfaces (5)
Hide obsolete interfaces
See also
var requirement: Package.Dependency.Requirement
The dependency requirement of the package dependency.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (25) members.
Types
enum Kind
The type of dependency.
enum RegistryRequirement
An enum that represents the requirement for a package dependency.
enum SourceControlRequirement
An enum that represents the requirement for a package dependency.
Type members
static func package(id: String, ClosedRange<Version>
) -> Package.Dependency Adds a package dependency starting with a specific minimum version, going up to and including a specific maximum version.
static func package(id: String, Range<Version>
) -> Package.Dependency Adds a package dependency starting with a specific minimum version, up to but not including a specified maximum version.
static func package(id: String, exact: Version
) -> Package.Dependency Adds a package dependency that uses the exact version requirement.
static func package(id: String, from: Version
) -> Package.Dependency Adds a package dependency that uses the version requirement, starting with the given minimum version, going up to the next major version.
static func package(name: String, path: String
) -> Package.Dependency Adds a dependency to a package located at the given path on the filesystem.
static func package(path: String
) -> Package.Dependency Adds a dependency to a package located at the given path.
static func package(url: String, ClosedRange<Version>
) -> Package.Dependency Adds a package dependency starting with a specific minimum version, going up to and including a specific maximum version.
static func package(url: String, Range<Version>
) -> Package.Dependency Adds a package dependency starting with a specific minimum version, up to but not including a specified maximum version.
static func package(url: String, branch: String
) -> Package.Dependency Adds a remote package dependency given a branch requirement.
static func package(url: String, exact: Version
) -> Package.Dependency Adds a package dependency that uses the exact version requirement.
static func package(url: String, from: Version
) -> Package.Dependency Adds 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, revision: String
) -> Package.Dependency Adds a remote package dependency given a revision requirement.
Show obsolete interfaces (7)
Hide obsolete interfaces
static func package(name: String?, url: String, Package.Dependency.Requirement
) -> Package.Dependency Adds a remote package dependency with a given version requirement.
static func package(name: String, url: String, ClosedRange<Version>
) -> Package.Dependency Adds a package dependency starting with a specific minimum version, going up to and including a specific maximum version.
static func package(name: String, url: String, Range<Version>
) -> Package.Dependency Adds a package dependency starting with a specific minimum version, up to but not including a specified maximum version.
static func package(name: String, url: String, branch: String
) -> Package.Dependency Adds a remote package dependency given a branch requirement.
static func package(name: String, url: String, from: Version
) -> Package.Dependency Adds a package dependency that uses the version requirement, starting with the given minimum version, going up to the next major version.
static func package(name: String, url: String, revision: String
) -> Package.Dependency Adds a remote package dependency given a revision requirement.
static func package(url: String, Package.Dependency.Requirement
) -> Package.Dependency Adds a remote package dependency given a version requirement.
Instance members
let kind: Package.Dependency.Kind
A description of the package dependency.
Show obsolete interfaces (2)
Hide obsolete interfaces
var name: String?
The name of the dependency.
var url: String?
The Git URL of the package dependency.
Citizens in PackageDescription
Type members
Show obsolete interfaces (5)
Hide obsolete interfaces
static func branch(String
) -> Package.Dependency.Requirement Returns a requirement for a source control branch.
static func exact(Version
) -> Package.Dependency.Requirement Returns a requirement for the given exact version.
static func revision(String
) -> Package.Dependency.Requirement Returns a requirement for a source control revision such as the hash of a commit.
static func upToNextMajor(from: Version
) -> Package.Dependency.Requirement A source control requirement bounded to the given version’s major version number.
static func upToNextMinor(from: Version
) -> Package.Dependency.Requirement A source control requirement bounded to the given version’s minor version number.