Version Structure Reference

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.

  • 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 take Int over UInt where possible.

    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 take Int over UInt where possible.

    Declaration

    Swift

    @inlinable
    public init(major: Int, minor: Int, patch: Int, prereleaseIdentifiers: [String] = [], buildMetadataIdentifiers: [String] = [])
  • Represents 0.0.0

    Declaration

    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.0 is less than 1.0.1, 1.0.1-alpha is less than 1.0.1 but greater than 1.0.0.

    Declaration

    Swift

    public static func < (lhs: Version, rhs: Version) -> Bool

    Return Value

    true if lhs is less than rhs

  • Creates a version object from a string.

    Note

    Returns nil if the string is not a valid semantic version.

    Declaration

    Swift

    public init?(_ string: String)

    Parameters

    string

    The 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.

    Declaration

    Swift

    init?<S>(tolerant: S) where S : StringProtocol