Latest 0.6.3
Homepage https://github.com/mrackwitz/Version
License MIT
Platforms ios 8.0, osx 10.10, watchos 2.0, tvos 9.0, requires ARC
Authors

CI Status

Version is a Swift Library, which enables to represent and compare semantic version numbers.
It follows Semantic Versioning 2.0.0.

The representation is:

  • Comparable
  • Hashable & Equatable
  • String Literal Convertible
  • Printable

Usage

Versions could be either instantiated directly:

let version = Version(major: 1, minor: 2, patch: 3, prerelease: "alpha.1", build: "B001")

Or they can be converted from a string literal:

let version : Version = "1.2.3-alpha.1+B001"

Versions can be compared between each other:

let version : Version = UIDevice.currentDevice().systemVersion
if version > "8.0" {
    // do something in a more amazing way
} else if version > "7.0"
    // do it an old-fashioned, legacy-style
} else {
    // do not care …
}

Besides UIKit’s UIDevice the more preferable variant to access
the operation system version in Foundation as shown below is supported, too.

let version : Version = NSProcessInfo.processInfo().operationSystemVersion
if version == "8.0.1" {
    NSLog("Sorry no cellular data for you, my friend!")
}

Finally Versions can be directly read from bundles:

if NSBundle(path: "Alamofire.framework").version! < "1.0.0" {
    println("Howdy Ho! Such an early-adopter using an unstable version!")
    println("Beware: “Anything may change at any time.”")

    // … or insert an actual meaningful special handling
    // for version-specific *implementation details* here.
}

ATTENTION: Take care when you check versions of frameworks.
Such checks happen at runtime. They can hurt performance if used at the wrong
place. If there are API changes and you want to consume new methods, you have
to do that at compile time by checking with precompiler macros (#if)
for definitions, which have been passed to the compiler build setting
OTHER_SWIFT_FLAGS.

Installation

Version is available through CocoaPods. To install
it, simply add the following lines to your Podfile:

use_frameworks!
pod 'Version'

Author

Marius Rackwitz, [email protected]
Find me on Twitter as @mrackwitz.

License

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

Latest podspec

{
    "name": "Version",
    "version": "0.6.3",
    "summary": "Version represents and compares semantic versions in Swift.",
    "description": "Version is a Swift Library, which enables to represent and compare semantic version numbers.nIt follows [Semantic Versioning 2.0.0](http://semver.org).nnThe representation is:n* Comparablen* Equatablen* String Literal Convertiblen* Printable",
    "homepage": "https://github.com/mrackwitz/Version",
    "license": "MIT",
    "authors": {
        "Marius Rackwitz": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mrackwitz/Version.git",
        "tag": "0.6.3"
    },
    "social_media_url": "https://twitter.com/mrackwitz",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "source_files": "Version/*.swift",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This