A type used for storing a version number containing a major number, and an optional minor and patch number.
A version can be initialized from individual version numbers.
Version(1, 0, 2) // 1.0.2The minor and patch numbers are optional.
Version(1) // 1A version can also be initialized from a string.
Version("1.2.3") // 1.2.3The version can be converted to a string.
Version(1, 0, 2).string // "1.0.2"The type also conforms to Comparable for comparing version numbers, and Codable for encoding and decoding.
Version is distributed using the Swift Package Manager. To install it within another Swift package, add it as a dependency within your Package.swift manifest:
let package = Package(
// . . .
dependencies: [
.package(url: "https://github.com/mattcox/Version.git", branch: "main")
],
// . . .
)If you’d like to use Version within an application on Apple platforms, then use Xcode’s File > Add Packages... menu command to add it to your project.
Import Version wherever you’d like to use it:
import Version