Version
public struct Version
extension Version: Codable
extension Version: Hashable
extension Version: Equatable
extension Version: Comparable
extension Version: LosslessStringConvertible
A struct representing a “semver” version, that is: a Semantic Version.
See also
https://semver.org-
The major version.
Declaration
Swift
public let major: Int -
The minor version.
Declaration
Swift
public let minor: Int -
The patch version.
Declaration
Swift
public let patch: Int -
The pre-release identifiers (if any).
Declaration
Swift
public let prereleaseIdentifiers: [String] -
The build metadatas (if any).
Declaration
Swift
public let buildMetadataIdentifiers: [String] -
Create a version object.
Note
Integers are made absolute since negative integers are not allowed, yet it is conventional Swift to takeIntoverUIntwhere possible.Remark
This initializer variant provided for more readable code when initializing with static integers.Declaration
Swift
@inlinable public init(_ major: Int, _ minor: Int, _ patch: Int, pre: [String] = [], build: [String] = []) -
Creates a version object.
Note
Integers are made absolute since negative integers are not allowed, yet it is conventional Swift to takeIntoverUIntwhere possible.Remark
This initializer variant provided when it would be more readable than the nameless variant.Declaration
Swift
@inlinable public init(major: Int, minor: Int, patch: Int, prereleaseIdentifiers: [String] = [], buildMetadataIdentifiers: [String] = []) -
Represents
0.0.0Declaration
Swift
public static let null: Version -
Declaration
Swift
public init(from decoder: Decoder) throws -
Declaration
Swift
public func encode(to encoder: Encoder) throws -
Declaration
Swift
public func hash(into hasher: inout Hasher) -
Compares the provided versions without comparing any build-metadata
Declaration
Swift
public static func == (lhs: Version, rhs: Version) -> Bool -
1.0.0is less than1.0.1,1.0.1-alphais less than1.0.1but greater than1.0.0.Declaration
Swift
public static func < (lhs: Version, rhs: Version) -> BoolReturn Value
trueiflhsis less thanrhs -
Creates a version object from a string.
Note
Returnsnilif the string is not a valid semantic version.Declaration
Swift
public init?(_ string: String)Parameters
stringThe string to parse.
-
Undocumented
Declaration
Swift
public init?<S>(_ string: S) where S : StringProtocol -
Returns the lossless string representation of this semantic version.
Declaration
Swift
public var description: String { get } -
Creates a version object.
Remark
This initializer variant uses a more tolerant parser, eg.10.1parses toVersion(10,1,0).Remark
This initializer will not recognizer builds-metadata-identifiers.Remark
Tolerates an initialvcharacter.Declaration
Swift
init?<S>(tolerant: S) where S : StringProtocol
View on GitHub
Version Structure Reference