Unstable-version Error of Swift Package Manager

My package needs Reachability framework. However, the author doesn't support Swift PM. There is other fork that supports SPM. So I tried that fork. The fork worked in my package. However, when I released my package and tried to use it in my project, the project complained that the Reachability was an unstable-version and could not be built with my project.

I first thought was that the master branch was unstable. So I forked the forked version and labelled it as "3.5" version. However, this time SPM complained that Reachability was still unstable.

What I should do to make it stable?

Package.swift of My Package

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "MyHost",
    defaultLocalization: "en",
    platforms: [
        .macOS(.v11),
        .iOS(.v14)
    ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "MyHost",
            targets: ["MyHost"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(url: "git@github.com:owenzhao/Reachability.git", Package.Dependency.Requirement.branch("3.5")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "MyHost",
            dependencies: ["Reachability"]),
        .testTarget(
            name: "MyHostTests",
            dependencies: ["MyHost", "Reachability"])
    ]
)

Package.swift of My forked Reachability framework


import PackageDescription

let package = Package(
    name: "Reachability",
    platforms: [
        .iOS(.v9),
        .macOS(.v10_10),
        .tvOS(.v9),
    ],
    products: [
        .library(
            name: "Reachability",
            targets: ["Reachability"]),
    ],
    dependencies: [],
    targets: [
        .target(
            name: "Reachability"),
    ]
)

git links

How to representing the issue

  1. create a new macOS app in Xcode
  2. add MyHost in SPM

The adding always fails, and choose add anyway. Build your app and issue shows.

@Zhao_Xin

.package(url: "git@github.com:owenzhao/Reachability.git", Package.Dependency.Requirement.branch("3.3")),

Your dependency here is a branch, a branch means a variable, an unstable version
You can set tag dependencies

But for this fork, only brach worked. When I chose range, Xcode complained "Failed to parse the manifest file".

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "IP Tool",
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "IP Tool",
            targets: ["IP Tool"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(url: "git@github.com:owenzhao/QRCodeKit.git", from: "1.0.0"),
//        .package(url: "git@github.com:owenzhao/Reachability.git", "3.3"..<"4.0"),  // can't use
        .package(url: "git@github.com:owenzhao/Reachability.git", branch: "3.5"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "IP Tool",
            dependencies: ["QRCodeKit", "Reachability"]),
        .testTarget(
            name: "IP ToolTests",
            dependencies: ["IP Tool", "QRCodeKit", "Reachability"]),
    ]
)

Any ideas?

I stopped using Reachability. Now I am using Network to do the same job. However, I am still wondering what is wrong here.

SPM only considers tags with a version strings to be stable.


Reading the error message is always helpful. A valid semantic version string consists of three numbers, not two. Also verify the package has a version tag in the range you specify for one of its commits.

I did not know that the version number must be 3 digit. As on github, many frameworks are using two digits. Some are even using "v" before digits, like "v3.0". So I thought two digits version was OK.

I did notice the error message. But Xcode only said it failed to parse the manifest file. The error message showed by Xcode didn't contain the version number was the issue. So I am wondering which app give the detail messages like yours. So I may try next time?

In report navigator, click the event which you get an error.
And in the right, click the "expand" button to see more detailed error message


1 Like

You should read the semver specification.