JPMartha's Pancake

This blog is the way to brush up my poor English.

How to depend on a beta version of package with the Swift Package Manager 🐣

👉 I organized on the next entry❗️


👉 日本語


Himotoki 2.0.0-beta.1 is released as a Pre-release, so I tried downloading and building the dependency with the Swift Package Manager .💥 

Himotoki is a type-safe JSON decoding library purely written in Swift.

The auther of the library is @ikesyo (Syo Ikeda). He is a speaker at try! Swift conference, and also is contributing to several open source projects such as ReactiveCocoa and Carthage.

Overview

If your project depends on a beta version of the package (for example Himotoki 2.0.0-beta.1) :

  • Set majorVersion: 2 , then Himotoki is not found 🙅
  • Set majorVersion: 1 , then Himotoki-1.7.0 is downloaded. 🙍
  • Set versions: Version(1,0,0)..<Version(2,0,0) ,  then Himotoki-2.0.0-beta.1 is downloaded. 🙆

P.S.

  • Set Version(2, 0, 0, prereleaseIdentifiers: ["beta", "1"])) ,  then Himotoki-2.0.0-beta.1 is downloaded. 🙆

Note

  • Please note, the Swift Package Manager is still in early design and development. ⚠️
  • I don't verify enough. 🐣
  • If there are some mistakes, please feel free to correct them. 🙏
  • The following example project TryKit depends on Himotoki. 💁

Package.swift — The Manifest File

Set majorVersion: 2

import PackageDescription

let package = Package(
    name: "TryKit",
    dependencies: [
        .Package(url: "https://github.com/ikesyo/Himotoki.git",
            majorVersion: 2)
    ]
)

To start the Swift build process, run the following command at the root of your project in Terminal.app:

$ swift build

👇

Himotoki is not found. 🙅

Cloning https://github.com/ikesyo/Himotoki.git

error: The dependency graph could not be satisfied. The package (https://github.com/ikesyo/Himotoki.git) with version tag in range (2.0.0..<2.9223372036854775807.9223372036854775807) is not found. Found tags ([0.4.1, 0.4.2, 0.5.1, 0.5.2, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.5.0, 1.6.0, 1.7.0, 2.0.0-beta.1])

Set majorVersion: 1

import PackageDescription

let package = Package(
    name: "TryKit",
    dependencies: [
        .Package(url: "https://github.com/ikesyo/Himotoki.git",
            majorVersion: 1)
    ]
)
$ swift build

👇

Himotoki-1.7.0 is downloaded. 😅

Cloning https://github.com/ikesyo/Himotoki.git

Resolved version: 1.7.0

...

Set versions: Version(1,0,0)..<Version(2,0,0)

import PackageDescription

let package = Package(
    name: "TryKit",
    dependencies: [
        .Package(url: "https://github.com/ikesyo/Himotoki.git",
            versions: Version(1,0,0)..<Version(2,0,0))
    ]
)
$ swift build

👇

Himotoki-2.0.0-beta.1 is downloaded. 🤔

Cloning https://github.com/ikesyo/Himotoki.git

Resolved version: 2.0.0-beta.1

...

P.S.

Set Version as the following, then Himotoki-2.0.0-beta.1 is downloaded. 😬

let package = Package(
    name: "TryKit",
    dependencies: [
        .Package(url: "https://github.com/ikesyo/Himotoki.git",
            Version(2, 0, 0, prereleaseIdentifiers: ["beta", "1"]))
    ]
)

Is this the right answer? 🙄

Let me make sure. 🙏

👉 I organized on the next entry❗️