By conforming to the SemanticVersioning protocol, it can be represented as a type that behaves as a version of software compliant with Semantic Versioning (2.0.0).
import SemanticVersioning
// conforms to SemanticVersioning
struct MyAppVersion: SemanticVersioning {
let major: Int
let minor: Int
let patch: Int
let preRelease: PreRelease?
let buildMetaData: String?
}
Can be initialized from String literals.
let appVersion: MyAppVersion = "1.1.1"
// String literals can also contain pre-release and build metadata.
// let appVersion: MyAppVersion = "1.1.1-alpha"
// let appVersion: MyAppVersion = "1.1.1-alpha+build.1"
Comparable and Equatable.
if appVersion > "1.0.0" {
// Some operation when appVersion is greater than 1.0.0
} else if appVersion == "0.1.0" {
// Some operation when appVersion is 0.1.0
}
SemanticVersioning [x.x.x]
This package provides the Swift protocol compatible with Semantic Versioning (2.0.0).
Features
By conforming to the
SemanticVersioning
protocol, it can be represented as a type that behaves as a version of software compliant with Semantic Versioning (2.0.0).Can be initialized from String literals.
Comparable and Equatable.
Increment version number.
Requirements
Supported Platforms
Usage
Package.swift
Add SemanticVersioning to your
Package.swift
dependencies:Add SemanticVersioning to your dependencies of
SemanticVersioning
target: