swiftversionversioningswift-package-managerswift-package

Swift Package Manager: dependency rules: "from" vs "upToNextMajor"


Let's consider a common format of listing a dependency inside the package:

.package(url: "ssh://git@bitbucket.org:firm/repo.git", from: "1.1.0"),

And this format:

.package(url: "ssh://git@bitbucket.org:firm/repo.git", .upToNextMajor("1.1.0"))

Are these declarations equivalent? Or will from declaration update even beyond the major version change, i.e. if 2.0.0 is available, it'll be installed?


Solution

  • Yes, these declarations are absolutely equivalent:

    .package(url: "ssh://git@bitbucket.org:firm/repo.git", from: "1.1.0"),
    
    .package(url: "ssh://git@bitbucket.org:firm/repo.git", .upToNextMajor("1.1.0"))
    

    And even in case of the from declaration the update to the next major version won't happen automatically and will require changing the major version to 2 or higher in the declaration.