{"id":13872317,"url":"https://github.com/SwiftPackageIndex/SemanticVersion","last_synced_at":"2025-07-16T02:30:40.735Z","repository":{"id":39748884,"uuid":"287720238","full_name":"SwiftPackageIndex/SemanticVersion","owner":"SwiftPackageIndex","description":"Represent semantic versions like \"1.0.0\" or \"1.2.3-beta1\" (SemVer) in Swift","archived":false,"fork":false,"pushed_at":"2024-07-22T12:03:00.000Z","size":64,"stargazers_count":56,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-17T17:39:48.777Z","etag":null,"topics":["semver"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SwiftPackageIndex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":"FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["SwiftPackageIndex"]}},"created_at":"2020-08-15T09:54:32.000Z","updated_at":"2024-11-02T18:02:31.000Z","dependencies_parsed_at":"2023-02-17T23:31:33.200Z","dependency_job_id":"331e1e2d-5f96-440a-a881-22f671f7d1fb","html_url":"https://github.com/SwiftPackageIndex/SemanticVersion","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":"0.11111111111111116","last_synced_commit":"61ef5ceb3bd8d5ce96e619c4015880b026289a1d"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftPackageIndex%2FSemanticVersion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftPackageIndex%2FSemanticVersion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftPackageIndex%2FSemanticVersion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftPackageIndex%2FSemanticVersion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwiftPackageIndex","download_url":"https://codeload.github.com/SwiftPackageIndex/SemanticVersion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226095683,"owners_count":17572970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["semver"],"created_at":"2024-08-05T23:00:39.528Z","updated_at":"2024-11-23T20:30:54.648Z","avatar_url":"https://github.com/SwiftPackageIndex.png","language":"Swift","readme":"[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FSwiftPackageIndex%2FSemanticVersion%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/SwiftPackageIndex/SemanticVersion)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FSwiftPackageIndex%2FSemanticVersion%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/SwiftPackageIndex/SemanticVersion)\n\n# 🏷 SemanticVersion\n\nSemanticVersion is a simple `Codable`, `Comparable`, `Equatable`, `Hashable`, and `LosslessStringConvertible` struct that can represent semantic versions.\n\nHere's what using `SemanticVersion` looks like in practise:\n\n```swift\nimport SemanticVersion\nimport Foundation\n\n// Query semantic version components\nlet v123 = SemanticVersion(1, 2, 3)\nv123.isStable        // true\nv123.isPreRelease    // false\nv123.isMajorRelease  // false\nv123.isMinorRelease  // false\nv123.isPatchRelease  // true\n\n// Parse semantic version from String\nlet v200 = SemanticVersion(\"2.0.0\")!\nv200.isStable        // true\nv200.isPreRelease    // false\nv200.isMajorRelease  // true\nv200.isMinorRelease  // false\nv200.isPatchRelease  // false\n\n// Supports beta versions\nlet v300rc1 = SemanticVersion(\"3.0.0-rc1-test\")!\nv300rc1.isStable        // false\nv300rc1.isPreRelease    // true\nv300rc1.isMajorRelease  // false\nv300rc1.isMinorRelease  // false\nv300rc1.isPatchRelease  // false\nv300rc1.major           // 3\nv300rc1.minor           // 0\nv300rc1.patch           // 0\nv300rc1.preRelease      // \"rc1-test\"\n\n// SemanticVersion is Comparable and Equatable\nv123 \u003c v200          // true\nSemanticVersion(\"2.0.0\")! \u003c SemanticVersion(\"2.0.1\")!  // true\n// NB: beta versions come before their releases\nSemanticVersion(\"2.0.0\")! \u003e SemanticVersion(\"2.0.0-b1\")!  // true\nv123 == SemanticVersion(\"1.2.3\")  // true\nSemanticVersion(\"v1.2.3-beta1+build5\")\n    == SemanticVersion(1, 2, 3, \"beta1\", \"build5\")  // true\n\n// SemanticVersion is Hashable\nlet dict = [         // [{major 3, minor 0, patch 0,...\n    v123: 1,\n    v200: 2,\n    v300rc1: 3\n]\n\n// SemanticVersion is Codable\n// Note: the strategy defaults to `.defaultCodable`\nlet defaultEncoder = JSONEncoder()\ndefaultEncoder.semanticVersionEncodingStrategy = .defaultCodable\nlet defaultDecoder = JSONDecoder()\ndefaultDecoder.semanticVersionDecodingStrategy = .defaultCodable\nlet defaultData = try defaultEncoder.encode(v123)  // 58 bytes\nlet defaultDecoded = try defaultDecoder.decode(SemanticVersion.self, from: defaultData)  // 1.2.3\ndefaultDecoded == v123  // true\n\nlet stringEncoder = JSONEncoder()\nstringEncoder.semanticVersionEncodingStrategy = .semverString\nlet stringDecoder = JSONDecoder()\nstringDecoder.semanticVersionDecodingStrategy = .semverString\nlet stringData = try stringEncoder.encode(v123) // 7 bytes -\u003e \"1.2.3\", including quotes\nlet stringDecoded = try stringDecoder.decode(SemanticVersion.self, from: stringData)  // 1.2.3\nstringDecoded == v123  // true\n```\n","funding_links":["https://github.com/sponsors/SwiftPackageIndex"],"categories":["Swift"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftPackageIndex%2FSemanticVersion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSwiftPackageIndex%2FSemanticVersion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftPackageIndex%2FSemanticVersion/lists"}