<!--
{
  "availability" : [
    "SwiftPM: 5.5.0 - 5.6.0"
  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/Package/Dependency/package(name:url:branch:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription0A0C10DependencyC7package4name3url6branchAESS_S2StFZ"
  },
  "title" : "package(name:url:branch:)"
}
-->

# package(name:url:branch:)

Adds a remote package dependency with a branch requirement you provide.

```
static func package(name: String, url: String, branch: String) -> Package.Dependency
```

## Parameters

`name`

The name of the package, or nil to deduce it from the URL.

`url`

The valid Git URL of the package.

`branch`

A dependency requirement. See static methods on [`Package.Dependency.Requirement`](/documentation/PackageDescription/Package/Dependency/Requirement-swift.enum) for available options.

## Return Value

A `Package.Dependency` instance.

## Discussion

```swift
.package(url: "https://example.com/example-package.git", branch: "main"),
```

---

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)