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

# package(url:branch:)

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

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

## Parameters

`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"),
```

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)