JPMartha's Pancake

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

#swiftlang Discussion with The Swift Package Manager ๐Ÿค”

Updated: 2016-03-24


The purpose of this entry is to prepare myself for a discussion. ๐Ÿ’ช

If there are some mistakes, please feel free to correct them. ๐Ÿ™

ใ“ใฎ่จ˜ไบ‹ใฎ็›ฎ็š„ใฏ่ญฐ่ซ–ใซๅ‘ใ‘ใฆ่‡ชๅˆ†่‡ช่บซใงๆ•ด็†ใ™ใ‚‹ใ“ใจใงใ™ใ€‚๐Ÿ’ช

ใ‚‚ใ—่ชคใ‚ŠใŒใ‚ใ‚Œใฐๆ•™ใˆใฆใใ ใ•ใ„ใ€‚๐Ÿ™

Overview

The Swift Package Manager is still in early design and development. โš ๏ธ

We have discussed with it in the Swift.org community in parallel. ๐Ÿค—

For more information, please see the following: ๐Ÿ’

Swift Package Manager ใฏใพใ ๅˆๆœŸๆฎต้šŽใงใ™ใ€‚โš ๏ธ

Swift.org community ใงไธฆ่กŒใ—ใฆ่ญฐ่ซ–ใ—ใฆใ„ใพใ™ใ€‚๐Ÿค—

่ฉณใ—ใใฏไปฅไธ‹ใ‚’ๅ‚็…งใ—ใฆใใ ใ•ใ„ใ€‚๐Ÿ’

Mailing Lists

GitHub

and so on.

Issues

  • Implementation of Version Structure
  • Consideration for Pre-release Versions
  • Dependency Version Locking (such as Carthage using Cartfile.resolved)
  • Version Structure ใฎๅฎŸ่ฃ…
  • ใƒ—ใƒฌใƒชใƒชใƒผใ‚น็‰ˆใธใฎ่€ƒๆ…ฎ
  • ๏ผˆCarthage ใงไฝฟใฃใฆใ„ใ‚‹ Cartfile.resolved ใฎใ‚ˆใ†ใช๏ผ‰ใƒคใƒ„

Current Status

Example 1

Environment

  • OS X 10.11.4 (15E65)
  • Apple Swift version 3.0-dev (LLVM 699a786c15, Clang 77080f2c03, Swift d22638766e) - swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a

Packageโ€™s Dependency

Releases of Himotoki (Git tag)

  • ...
  • 1.7.0
  • 2.0.0-beta.1 (Pre-release)
  • 2.0.0-beta.2 (Pre-release)

Implementation of Package.swift

I intend to download Himotoki 2.0.0-beta.1.

import PackageDescription

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

When running the $ swift build --fetch command,

Himotoki 2.0.0-beta.2 is downloaded. ๐Ÿ™…

$ swift build --fetch

Cloning https://github.com/ikesyo/Himotoki.git
Resolved version: 2.0.0-beta.2

Example 2

  • "2.0.0-beta.1"..."2.0.0-beta.1"

I think this implementation is recommended in the mailing lists section.

.Package(url: "https://github.com/ikesyo/Himotoki.git",
    versions: Version(2, 0, 0, prereleaseIdentifiers: ["beta.1"])...Version(2, 0, 0, prereleaseIdentifiers: ["beta.1"]))

Himotoki 2.0.0-beta.2 is downloaded. ๐Ÿ™…

$ swift build --fetch

Cloning https://github.com/ikesyo/Himotoki.git
Resolved version: 2.0.0-beta.2

Example 3

  • "2.0.0-beta.1"
.Package(url: "https://github.com/ikesyo/Himotoki.git",
    Version(2, 0, 0, prereleaseIdentifiers: ["beta.1"]))

Himotoki 2.0.0-beta.2 is downloaded. ๐Ÿ™…

$ swift build --fetch

Cloning https://github.com/ikesyo/Himotoki.git
Resolved version: 2.0.0-beta.2

Example 4

  • "2.0.0-beta.1"..."2.0.0-beta.1"
.Package(url: "https://github.com/ikesyo/Himotoki.git",
    versions: Version(2, 0, 0, prereleaseIdentifiers: ["beta", "1"])...Version(2, 0, 0, prereleaseIdentifiers: ["beta", "1"]))

Himotoki 2.0.0-beta.2 is downloaded. ๐Ÿ™…

$ swift build --fetch

Cloning https://github.com/ikesyo/Himotoki.git
Resolved version: 2.0.0-beta.2

Example 5

  • "2.0.0-beta.1"..<"2.0.0-beta.2"
.Package(url: "https://github.com/ikesyo/Himotoki.git",
    versions: Version(2, 0, 0, prereleaseIdentifiers: ["beta", "1"])..<Version(2, 0, 0, prereleaseIdentifiers: ["beta", "2"]))

Himotoki 2.0.0-beta.1 is downloaded. ๐Ÿ™†

$ swift build --fetch

Cloning https://github.com/ikesyo/Himotoki.git
Resolved version: 2.0.0-beta.1

Reference

Implementation of The Package Class

https://github.com/apple/swift-package-manager/blob/swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a/Sources/PackageDescription/Package.swift#L29-L40

public class func Package(url url: String, versions: Range<Version>) -> Dependency {
    return Dependency(url, versions)
}
public class func Package(url url: String, majorVersion: Int) -> Dependency {
    return Dependency(url, Version(majorVersion, 0, 0)..<Version(majorVersion, .max, .max))
}
public class func Package(url url: String, majorVersion: Int, minor: Int) -> Dependency {
    return Dependency(url, Version(majorVersion, minor, 0)..<Version(majorVersion, minor, .max))
}
public class func Package(url url: String, _ version: Version) -> Dependency {
    return Dependency(url, version...version)
}

Others