swift-version-compare

2.0.3

Create and compare semantic versions in swift.
mflknr/swift-version-compare

What's New

2.0.3

2024-06-17T11:57:13Z

Added

  • Dependabot for checking gihub-actions updates
  • Support for VisionOS
  • .spi.yml for automated DocC generation on the Swift Package Index

Changed

  • Documentation syntax to DocC
  • SwiftLint to 0.55.1
  • SwiftFormat to 0.54.0

Removed

  • jazzy documentation generation

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

swift-version-compare

licence

A package introducing a Version object implementing the SemanticVersionComparable protocol for comparing versions conforming to SemVer.

Installation

Swift Package Manager:

.package(url: "https://github.com/mflknr/swift-version-compare.git", from: "2.0.0"))

Usage

For detailed implementation information see documentation.

// use the version core identifier for initialization
let versionOne = Version(1, 0, 0)
let versionTwo = Version(
    major: 1,
    minor: 0,
    patch: 0,
    prerelease: [.alpha],
    build: ["1"]
) // -> prints: "1.0.0-alpha+1"

// use strings
// use `ExpressibleByStringLiteral` with caution, because it's fatal if string is not `SemVer` version
let versionThreeA: Version? = "1.0.0" 
let versionThreeB: Version? = Version("1.0.0")

// easy initial `0.0.0` version
let initialVersion: Version = .initial

// from bundle and processInfo
let bundleVersion = Bundle.main.shortVersion
let osVersion = ProcessInfo.processInfo.comparableOperatingSystemVersion

// compare versions with usally known operators (==, ===, <, <=, >=, >)
if Version("1.0.0") > Version("0.4.0") {
    // ...
}

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 03:50:30 GMT-0900 (Hawaii-Aleutian Daylight Time)