EXTENSION
Package
extension PackageMethods
package(url:from:)
public static func package(url: String, from version: Version) -> PackageCreate a package dependency that uses the version requirement, starting with the given minimum version, going up to the next major version.
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.
.package(url: "https://example.com/example-package.git", from: "1.2.3"),
- Parameters:
- url: The valid Git URL of the package.
- version: The minimum version requirement.
Parameters
| Name | Description |
|---|---|
| url | The valid Git URL of the package. |
| version | The minimum version requirement. |
package(url:_:)
public static func package(url: String, _ requirement: Package.Requirement) -> PackageAdd a remote package dependency given a version requirement.
- Parameters:
- url: The valid Git URL of the package.
- requirement: A dependency requirement. See static methods on
Package.Requirementfor available options.
Parameters
| Name | Description |
|---|---|
| url | The valid Git URL of the package. |
| requirement | A dependency requirement. See static methods on Package.Requirement for available options. |
package(url:_:)
public static func package(url: String, _ range: Range<Version>) -> PackageAdd a package dependency starting with a specific minimum version, up to but not including a specified maximum version.
The following example allows the Swift package manager to pick versions 1.2.3, 1.2.4, 1.2.5, but not 1.2.6.
.package(url: "https://example.com/example-package.git", "1.2.3"..<"1.2.6"),
- Parameters:
- url: The valid Git URL of the package.
- range: The custom version range requirement.
Parameters
| Name | Description |
|---|---|
| url | The valid Git URL of the package. |
| range | The custom version range requirement. |
package(url:_:)
public static func package(url: String, _ range: ClosedRange<Version>) -> PackageAdd a package dependency starting with a specific minimum version, going up to and including a specific maximum version.
The following example allows the Swift package manager to pick versions 1.2.3, 1.2.4, 1.2.5, as well as 1.2.6.
.package(url: "https://example.com/example-package.git", "1.2.3"..."1.2.6"),
- Parameters:
- url: The valid Git URL of the package.
- range: The closed version range requirement.
Parameters
| Name | Description |
|---|---|
| url | The valid Git URL of the package. |
| range | The closed version range requirement. |
package(path:)
public static func package(path: Path) -> PackageAdd a dependency to a local package on the filesystem.
The Swift Package Manager uses the package dependency as-is and does not perform any source control access. Local package dependencies are especially useful during development of a new package or when working on multiple tightly coupled packages.
- Parameter path: The path of the package.
Parameters
| Name | Description |
|---|---|
| path | The path of the package. |
package(id:from:)
public static func package(id: String, from version: Version) -> PackageAdds a package dependency that uses the version requirement, starting with the given minimum version, going up to the next major version.
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.
.package(id: "scope.name", from: "1.2.3"),Parameters:
- id: The identity of the package.
- version: The minimum version requirement.
Returns: A
Packageinstance.
Parameters
| Name | Description |
|---|---|
| id | The identity of the package. |
| version | The minimum version requirement. |
package(id:exact:)
public static func package(id: String, exact version: Version) -> PackageAdds a package dependency that uses the exact version requirement.
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"),Parameters:
- id: The identity of the package.
- version: The exact version of the dependency for this requirement.
Returns: A
Packageinstance.
Parameters
| Name | Description |
|---|---|
| id | The identity of the package. |
| version | The exact version of the dependency for this requirement. |
package(id:_:)
public static func package(id: String, _ range: Range<Version>) -> PackageAdds a package dependency starting with a specific minimum version, up to but not including a specified maximum version.
The following example allows the Swift Package Manager to pick versions 1.2.3, 1.2.4, 1.2.5, but not 1.2.6.
.package(id: "scope.name", "1.2.3"..<"1.2.6"),The following example allows the Swift Package Manager to pick versions between 1.0.0 and 2.0.0
.package(id: "scope.name", .upToNextMajor(from: "1.0.0")),The following example allows the Swift Package Manager to pick versions between 1.0.0 and 1.1.0
.package(id: "scope.name", .upToNextMinor(from: "1.0.0")),Parameters:
- id: The identity of the package.
- range: The custom version range requirement.
Returns: A
Packageinstance.
Parameters
| Name | Description |
|---|---|
| id | The identity of the package. |
| range | The custom version range requirement. |
package(id:_:)
public static func package(id: String, _ range: ClosedRange<Version>) -> PackageAdds a package dependency starting with a specific minimum version, going up to and including a specific maximum version.
The following example allows the Swift Package Manager to pick versions 1.2.3, 1.2.4, 1.2.5, as well as 1.2.6.
.package(id: "scope.name", "1.2.3"..."1.2.6"),Parameters:
- id: The identity of the package.
- range: The closed version range requirement.
Returns: A
Packageinstance.
Parameters
| Name | Description |
|---|---|
| id | The identity of the package. |
| range | The closed version range requirement. |
