<!--
{
  "availability" : [
    "SwiftPM: 5.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/Package/Dependency/package(id:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription0A0C10DependencyC7package2id4fromAESS_AA7VersionVtFZ"
  },
  "title" : "package(id:from:)"
}
-->

# package(id:from:)

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

```
static func package(id: String, from version: Version) -> Package.Dependency
```

## Parameters

`id`

The identity of the package.

`version`

The minimum version requirement.

## Return Value

A `Package.Dependency` instance.

## Discussion

This is the recommended way to specify a remote package dependency.
It allows you to specify the minimum version you require, allows updates that include bug fixes
and backward-compatible feature updates, but requires you to explicitly update to a new major version of the dependency.
This approach provides the maximum flexibility on which version to use,
while making sure you don’t update to a version with breaking changes,
and helps to prevent conflicts in your dependency graph.

The following example allows the Swift Package Manager to select a version
like a  `1.2.3`, `1.2.4`, or `1.3.0`, but not `2.0.0`.

```swift
.package(id: "scope.name", from: "1.2.3"),
```

If the package you depend on defines traits, the package manager uses the dependency with its default set of traits.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)