Skip to content

samuelwford/SWFSemanticVersion

Repository files navigation

SWFSemanticVersion

Version Platform

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

Usage

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];

Installation

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

pod "SWFSemanticVersion"

Author

Samuel Ford, [email protected]

Acknowledgements

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •