Latest 0.5.0
License MIT
Platforms osx , ios , tvos , watchos , requires ARC


A port of the semantic version value class from the semantic Ruby gem that implements the SemVer versioning scheme.


To run the example project; clone the repo, build and run with Xcode. The sample is an iOS app that you can type two semantic version strings into and display the comparison result.

Creating a Semantic Version

The SWFSemanticVersion class parses a string in the format defined by the standard and produces an immutable value object from it. If the version string can’t be parsed it returns nil.

Instances can be compared and follow the rules defined by the standard. Specifically, major > minor > patch. Pre-release < release, but two pre-release suffixes are compared lexically and numerically. Build suffixes are ignored for comparison.

For example:

  • 1.0.0 < 2.0.0 < 2.1.0 < 2.1.1
  • 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0

Create from a string (will return a nil if the string isn’t parseable):

SWFSemanticVersion *semVer = [SWFSemanticVersion semanticVersionWithString:@"0.1.0"];

Or create manually:

SWFSemanticVersion *semVer = [[SWFSemanticVersion alloc] initWithMajor:@(0) minor:@(0) patch:@(0) pre:nil build:nil];


SWFSemanticVersion is available through CocoaPods, to install
it simply add the following line to your Podfile:

pod "SWFSemanticVersion"


Samuel Ford, [email protected]



SWFSemanticVersion is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "SWFSemanticVersion",
    "version": "0.5.0",
    "summary": "A mutable value object implementation of SemVer.",
    "description": "Parses and compares strings that contain SemVer strings.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Samuel Ford": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.5.0"
    "requires_arc": true,
    "source_files": "SWFSemanticVersion/SWFSemanticVersion.*",
    "platforms": {
        "osx": null,
        "ios": null,
        "tvos": null,
        "watchos": null

Pin It on Pinterest

Share This