All options to specify a Swift package version

I am a Software Engineer working on open source and enterprise mobile SDKs for iOS and MacOS developers written in Swift. From 🇩🇪 and happily living in 🇺🇸
Search for a command to run...

I am a Software Engineer working on open source and enterprise mobile SDKs for iOS and MacOS developers written in Swift. From 🇩🇪 and happily living in 🇺🇸
No comments yet. Be the first to comment.
WWDC26 kicked off on June 8, 2026. The information in this article reflects the information published by Apple on that date. There are 14 new frameworks. Name Description AccessoryAccess Manage

WWDC25 kicked off on June 9, 2025. The information in this article reflects the information published by Apple on that date. New Frameworks NameDescription AlarmKitSchedule prominent alarms and countdowns to help people manage their time. AVR...

WWDC25 is almost here, and I couldn’t be more excited! Whether you're attending the official events, community meetups, or just soaking in the energy around Cupertino, there’s no better time to connect, share ideas, and celebrate everything we love a...

In this blog post, I’ll share an observation and advice regarding the caching behavior of network responses by Apple’s APIs. If you are unfamiliar with caching of network responses then I recommend Apple’s article Accessing cached data that introduce...
WWDC24 kicked off on June 10, 2024. The information in this article reflects the information published by Apple on that date. New Frameworks NameDescription AccessorySetupKitUse AccessorySetupKit to discover accessories with Bluetooth or Wi-Fi...

How you specify a remote package dependency determines if and how updates are resolved. Learn what the recommended way is and why. Even a daring option that lets you take any updates and skip several major versions.
Remote packages can be used as dependencies for an Xcode project or Swift package. All the listed functions below assume that you declare a package dependency in your Swift package manifest. Still, the same rules are also available when declaring a package dependency in your Xcode project.
Apple's 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.
// Adds a package dependency that uses the version requirement, starting with the given minimum version, going up to the next major version.
.package(url: "https://example.com/example-package.git", from: "1.2.3")
Example can resolve into a selected version like 1.2.3, 1.2.4, or 1.3.0, but not 2.0.0.
// Adds a package dependency starting with a specific minimum version, up to but not including a specified maximum version.
.package(url: "https://example.com/example-package.git", "1.2.3"..<"2.3.6")
Example can resolve into a selected version like 1.2.3, 1.2.4, 1.2.5, ..., 2.0.0, ..., 2.3.5 but not 2.3.6.
⚠️ Specifying a wide range allows the daring developer to uptake multiple or even any major version. Use with extreme caution! 💣
.package(url: "https://example.com/example-package.git", "2.0.0"..<"999.999.999")
// Adds a package dependency starting with a specific minimum version, going up to and including a specific maximum version.
.package(url: "https://example.com/example-package.git", "1.2.6"..."2.3.6")
Example can resolve into a selected version like 1.2.3, 1.2.4, 1.2.5, ..., 2.0.0, ..., 2.3.5 as well as 2.3.6.
Specifying exact version requirements are not recommended as they can cause conflicts in your dependency graph when multiple other packages depend on a package. As Swift packages follow the semantic versioning convention, think about specifying a version range instead.
// Adds a package dependency that uses the exact version requirement.
.package(url: "https://example.com/example-package.git", exact: "1.2.3")
Note that packages that use commit-based dependency requirements can’t be depended upon by packages that use version-based dependency requirements; you should remove commit-based dependency requirements before publishing a version of your package.
// Adds a remote package dependency given a revision requirement.
.package(url: "https://example.com/example-package.git", revision: "6297dc937f209f9d28f2c71f1c2623b20312648d")
Note that packages that use branch-based dependency requirements can’t be depended upon by packages that use version-based dependency requirements; you should remove branch-based dependency requirements before publishing a version of your package.
// Adds a remote package dependency given a branch requirement.
.package(url: "https://example.com/example-package.git, branch: "main")