Versioning is a lightweight, modern Swift library for working with semantic versioning.
It provides a simple and expressive API for defining, comparing, and validating version numbers.
- ✅ Intuitive
SemanticVersiontype - ✍️ Initialisers for integers, strings, and string literals
- 🔐 Safe comparisons with automatic version normalisation
- 📦 Codable, Comparable, Hashable, Sendable
- 🧪 Fully testable and platform-agnostic
Add this package via Swift Package Manager:
.product(name: "Versioning", package: "versioning")You can construct a version using individual components:
let version = SemanticVersion(major: 2, minor: 1, patch: 4)Or string literals.
let a: SemanticVersion = "1"
let b: SemanticVersion = "1.0"
let c: SemanticVersion = "1.0.0"
// normalised
assert(a == b)
assert(b == c)
assert(a == c)