{"id":16829729,"url":"https://github.com/mxcl/version","last_synced_at":"2025-04-09T05:10:29.546Z","repository":{"id":44357937,"uuid":"169986505","full_name":"mxcl/Version","owner":"mxcl","description":"semver (Semantic Version) Swift µFramework.","archived":false,"fork":false,"pushed_at":"2024-09-17T20:14:31.000Z","size":169,"stargazers_count":315,"open_issues_count":2,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T04:03:35.117Z","etag":null,"topics":["micro-framework","semver","swift"],"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/mxcl.png","metadata":{"funding":{"github":"mxcl","patreon":"mxcl"},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2019-02-10T14:24:58.000Z","updated_at":"2025-03-08T19:08:04.000Z","dependencies_parsed_at":"2024-06-21T02:13:14.555Z","dependency_job_id":"0df3c178-00b1-4d88-9dd9-9df6db194e88","html_url":"https://github.com/mxcl/Version","commit_stats":{"total_commits":41,"total_committers":4,"mean_commits":10.25,"dds":0.07317073170731703,"last_synced_commit":"d98e85563e6d8a8617b082c02870501252f122b5"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcl%2FVersion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcl%2FVersion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcl%2FVersion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcl%2FVersion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mxcl","download_url":"https://codeload.github.com/mxcl/Version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980837,"owners_count":21027808,"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":["micro-framework","semver","swift"],"created_at":"2024-10-13T11:35:21.858Z","updated_at":"2025-04-09T05:10:29.529Z","avatar_url":"https://github.com/mxcl.png","language":"Swift","funding_links":["https://github.com/sponsors/mxcl","https://patreon.com/mxcl","https://www.patreon.com/mxcl"],"categories":[],"sub_categories":[],"readme":"# Version ![badge-platforms][] ![badge-languages][] [![badge-ci][]][ci] [![badge-jazzy][]][docs] [![badge-codecov][]][codecov]\n\nA µ-framework for representing, comparing, encoding and utilizing\n[semantic versions][semver], eg. `1.2.3` or `2.0.0-beta`.\n\nThis is `Version.swift` from the [Swift Package Manager], with some minor\nadjustments:\n\n1. More compact `Codable` implementation †\n2. Implements `LosslessStringConvertible` ‡\n3. Not a massive-single-source-file (MSSF)\n4. [Online documentation][docs]\n5. Extensions for `Bundle` and `ProcessInfo`\n6. Removal of the potentially fatal `ExpressibleByStringLiteral` conformance\n7. A “tolerant” initializer for user input like `10.0` or `v3`\n8. Idiomatic implementations for `Range\u003cVersion\u003e`\n9. Initialization from `StringProtocol`, not just `String`\n\nWe have automatic monitoring for changes at Apple’s repo to alert us if we\nshould need merge any fixes.\n\n\u003e † [Semantic versions][semver] can be losslessly expressed as strings; thus we\n\u003e do so.\n\n\u003e ‡ Like `Int` we can losslessly store a semantic version from a valid string,\n\u003e so we conform to the same protocol.\n\n[semver]: https://semver.org\n[docs]: https://mxcl.dev/Version/Structs/Version.html\n[badge-platforms]: https://img.shields.io/badge/platforms-macOS%20%7C%20Linux%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Windows-lightgrey.svg\n[badge-languages]: https://img.shields.io/badge/swift-4.2%20%7C%205.x%20%7C%206.x-orange.svg\n[badge-jazzy]: https://raw.githubusercontent.com/mxcl/Version/gh-pages/badge.svg?sanitize=true\n[badge-codecov]: https://codecov.io/gh/mxcl/Version/branch/master/graph/badge.svg\n[badge-ci]: https://github.com/mxcl/Version/actions/workflows/checks.yml/badge.svg\n[ci]: https://github.com/mxcl/Version/actions\n[codecov]: https://codecov.io/gh/mxcl/Version\n[Swift Package Manager]: https://github.com/apple/swift-tools-support-core/blob/main/Sources/TSCUtility/Version.swift\n\n# Support mxcl\n\nHey there, I’m Max Howell. I’m a prolific producer of open source software and\nprobably you already use some of it (for example, I created [`brew`]). I work\nfull-time on open source and it’s hard; currently *I earn less than minimum\nwage*. Please help me continue my work, I appreciate it 🙏🏻\n\n\u003ca href=\"https://www.patreon.com/mxcl\"\u003e\n\t\u003cimg src=\"https://c5.patreon.com/external/logo/become_a_patron_button@2x.png\" width=\"160\"\u003e\n\u003c/a\u003e\n\n[Other ways to say thanks](http://mxcl.dev/#donate).\n\n[`brew`]: https://brew.sh\n\n# Usage\n\n```swift\nimport Version\n\n// these two initializers are the same, use whichever suits the code context\nlet v1 = Version(1,0,0)\nlet v2 = Version(major: 1, minor: 0, patch: 0)\n\nlet v3 = Version(\"1.2.3\")           // =\u003e  1.2.3: Version?\nlet v4 = Version(tolerant: \"10.1\")  // =\u003e 10.1.0: Version?\nlet v5 = Version(tolerant: \"10\")    // =\u003e 10.0.0: Version?\n\n// a real Version object from your app’s Info.plist\nlet v6 = Bundle.main.version\n\nlet range = Version(1,2,3)..\u003cVersion(2,0,0)\n\nlet null: Version = .null  // =\u003e Version(0,0,0)\n\nlet foo = Version(1,2,3) \u003c Version(2,0,0)  // =\u003e true\n```\n\n# Installation\n\nSwiftPM:\n\n```swift\npackage.append(.package(url: \"https://github.com/mxcl/Version.git\", from: \"2.0.0\"))\n```\n\nCarthage:\n\n\u003e Waiting on: [@Carthage#1945](https://github.com/Carthage/Carthage/pull/1945).\n\n## Ranges\n\nRanges work as you expect, but there are caveats for prerelease identifiers,\nhere are the rules:\n\n\u003e  `1.0.0..\u003c2.0.0` does not include eg. `2.0.0-alpha`\n\nThis is probably what you expected. However:\n\n\u003e `1.0.0..\u003c2.0.0` also does not include eg. `1.5.0-alpha`\n\nHowever:\n\n\u003e `1.0.0..\u003c2.0.0-beta` **does** include eg. `2.0.0-alpha`\n\nThis is how the majority of Semantic Version libraries work.\n\n## Comparable, Equatable \u0026 Hashable\n\nBoth comparable and equatable ignore build metadata as per the specification. Thus:\n\n```swift\nVersion(\"1.2.3+14\") == Version(\"1.2.3+15\")  // =\u003e true\nVersion(\"1.2.3+14\") \u003c= Version(\"1.2.3+15\")  // =\u003e true\nVersion(\"1.2.3+14\") \u003c  Version(\"1.2.3+15\")  // =\u003e false\n```\n\nThis also means that `Hashable` must mirror this behavior, thus:\n\n```swift\ndict[Version(\"1.2.3+14\")] = 1\ndict[Version(\"1.2.3+15\")] = 2\ndict.count  // =\u003e 1\ndict        // =\u003e [\"1.2.3+15\": 2]\n```\n\nBe aware of this as it may catch you out, naturally this will also effect structures\nthat depend on `Hashable`, eg. `Set`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxcl%2Fversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmxcl%2Fversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxcl%2Fversion/lists"}