Blaszard Blaszard - 1 year ago 68
Swift Question

How to specify alpha version of a module in Package.swift?

I want to add a library called Markdown for my Swift project, which is a server-side build on Vapor.

However, it seems that the library have ditched supporting Swift 2.x, and now the latest version is 1.0.0-alpha, which is based on Swift 3.x.

Since my project is based on Swift 3.x, I want to fetch the library. The document says the following:

.Package(url: "", majorVersion: 0)

However, how can I specify the alpha version of the module in

Answer Source

You can specify version tag with prereleaseIdentifiers

Package(url: "http://...", "1.0.0-alpha")

More Info
The Package Dependency has many convenience initializers

.Package(url: String, versions: Range<Version>)
.Package(url: String, versions: ClosedRange<Version>)
.Package(url: String, majorVersion: Int)
.Package(url: String, majorVersion: Int, minor: Int)
.Package(url: String, _ version: Version)

Use examples:

.Package(url: "", versions: Version(1,0,0)..<Version(2,0,0))
.Package(url: "", majorVersion: 1)
.Package(url: "", majorVersion: 1, minor: 4)
.Package(url: "", Version(1,0,0))
.Package(url: "", "1.0.0")

The Version struct follows semantic versioning and has following format.

    _ major: Int,
    _ minor: Int,
    _ patch: Int,
    prereleaseIdentifiers: [String] = [],
    buildMetadataIdentifier: String? = nil

When making a Version instance you can also specify prerelease and buildMetadata identifiers

Version(0,1,0, prereleaseIdentifiers: ["alpha"], buildMetadataIdentifier: "10")

You can find more in Swift Package Manager repo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download