Contents

package(id:exact:traits:)

Adds a remote package dependency with an exact version requirement.

Declaration

static func package(id: String, exact version: Version, traits: Set<Package.Dependency.Trait> = [.defaults]) -> Package.Dependency

Parameters

  • id:

    The identity of the package.

  • version:

    The exact version of the dependency for this requirement.

  • traits:

    The trait configuration of this dependency. The default value enables the default traits of the package.

Return Value

A Package.Dependency instance.

Discussion

Specifying exact version requirements are not recommended as they can cause conflicts in your dependency graph when multiple other packages depend on a package. Because Swift packages follow the semantic versioning convention, think about specifying a version range instead.

The following example instructs the Swift Package Manager to use version 1.2.3.

.package(id: "scope.name", exact: "1.2.3"),

See Also

Creating a package dependency from a registry