All Projects → mrackwitz → Version

mrackwitz / Version

Licence: mit
Represent and compare versions via semantic versioning (SemVer) in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Version

Python Semver
Python package to work with Semantic Versioning (http://semver.org/)
Stars: ✭ 264 (+65%)
Mutual labels:  versioning, version, semver, semantic-versioning
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+660%)
Mutual labels:  tvos, watchos, cocoapods
Contentful.swift
A delightful Swift interface to Contentful's content delivery API.
Stars: ✭ 132 (-17.5%)
Mutual labels:  tvos, watchos, cocoapods
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-13.75%)
Mutual labels:  tvos, watchos, cocoapods
Cloudkitgdpr
Framework for allowing users to manage data stored in iCloud
Stars: ✭ 126 (-21.25%)
Mutual labels:  tvos, watchos, cocoapods
Fugen
Command line tool for exporting resources and generating code from your Figma files
Stars: ✭ 41 (-74.37%)
Mutual labels:  tvos, watchos, cocoapods
Predicateflow
Write amazing, strong-typed and easy-to-read NSPredicate.
Stars: ✭ 98 (-38.75%)
Mutual labels:  tvos, watchos, cocoapods
Xcake
🍰 Describe Xcode projects in a human readable format and (re)generate one on demand.
Stars: ✭ 549 (+243.13%)
Mutual labels:  tvos, watchos, cocoapods
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+6591.25%)
Mutual labels:  tvos, watchos, cocoapods
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-1.25%)
Mutual labels:  tvos, watchos, cocoapods
Color
Color utilities for macOS, iOS, tvOS, and watchOS
Stars: ✭ 145 (-9.37%)
Mutual labels:  tvos, watchos, cocoapods
Grabver
Gradle Automatic Build Versioning Plugin - An easy Gradle plugin that follows semver.org rules to automatically generate the Patch version, Build number and Code version, while Major, Minor and Pre-Release suffix remain under our control.
Stars: ✭ 39 (-75.62%)
Mutual labels:  versioning, version, semver
Open Source Ios Apps
📱 Collaborative List of Open-Source iOS Apps
Stars: ✭ 28,826 (+17916.25%)
Mutual labels:  tvos, watchos, cocoapods
Reckon
Infer a project's version from your Git repository.
Stars: ✭ 124 (-22.5%)
Mutual labels:  versioning, version, semver
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (+300.63%)
Mutual labels:  tvos, watchos, cocoapods
Swiftyattributes
A Swifty API for attributed strings
Stars: ✭ 1,303 (+714.38%)
Mutual labels:  tvos, watchos, cocoapods
Semver
Semantic versioning helper library for PHP
Stars: ✭ 144 (-10%)
Mutual labels:  versioning, semver, semantic-versioning
Swiftuipager
Native Pager in SwiftUI
Stars: ✭ 430 (+168.75%)
Mutual labels:  tvos, watchos, cocoapods
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (+229.38%)
Mutual labels:  tvos, watchos, cocoapods
Sdwebimagewebpcoder
A WebP coder plugin for SDWebImage, use libwebp
Stars: ✭ 101 (-36.87%)
Mutual labels:  tvos, watchos, cocoapods

Version

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 representation:

let version = try Version("1.2.3-alpha.1+B001")

let version: Version = "1.2.3-alpha.1+B001"
// The line above is equivalent to:
let version = try! Version("1.2.3-alpha.1+B001")

Versions can be compared between each other:

let version = Version(from: ProcessInfo.processInfo.operatingSystemVersion)

if version > "8.0.0" {
    // do something in a more amazing way
} else if version > "7.0.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(from: ProcessInfo.processInfo.operatingSystemVersion)
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

Swift Package Manager

.package(url: "https://github.com/mrackwitz/Version.git", ),

Cocoapods

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

use_frameworks!
pod 'Version'

Carthage

github "mrackwitz/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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].