Git Product home page Git Product logo

semanticversioning's Introduction

Semantic Versioning

Twitter: @ajax64 Platform Platform License Build and Test Swift Version

Semantic Versioning implementation in Swift! Use the struct Version to represent a version according to the Semantic Versioning Specification 2.0.0.

โœ… Fully Unit tested

โœ… 100% Swift

Getting Started

Requirements

  • iOS 11.0+ / Mac OS X 10.13+
  • Xcode 11+
  • Swift 5.0

Installation

The easiest way to use SemanticVersion in your project is using the CocaPods package manager.

Swift PM

See Adding Package Dependencies to Your App on how to use this library with Swift PM.

CocoaPods

See installation instructions for CocoaPods if not already installed

To integrate the library into your Xcode project specify the pod dependency to your Podfile:

platform :ios, '11.0'
use_frameworks!

pod 'SemanticVersioning'

run pod install

pod install

Usage

Create version 2.0.0

let version = Version(major: 2)

Create version 1.2.3

let version = Version(major: 1, minor: 2, patch: 3)

Create version 1.0.0-alpha.2

let version = Version(major: 1, preReleaseIdentifier: ["alpha", "2"])

Create version from a String

let version: Version = "1.3.10-rc"

Create a list of versions from a Array of Strings

let versions: [Version] = ["1.0.0-alpha", "1.0.0-alpha.1"]

Check if is prerelease version or not

if version.isPrerelease { ... }

Access the prerelease identifier via the preReleaseIdentifier Array

for identifier in version.preReleaseIdentifier
{
    // ...
}

Access the build metadata identifier via the buildMetadataIdentifier Array

for identifier in version.buildMetadataIdentifier
{
    // ...
}

Conforms to Printable so you can simply get a String representation by accessing the description property

print(version)
// OR
let stringRepresentation = version.description

mutability / immutability

Comparison

The default operators for comparison are implemented < , <= , > ,>= ,== , != This will compare major, minor, patch and the prerelease identifiers according to the Semantic Versioning Specification 2.0.0

Parser

The implementation includes a full-fledged component of parse String representation of a version. Please have a look at the tests and the source of SemanticVersioningParser for now ๐Ÿ˜‰

Tests

The library includes a suite of tests showing how to use the different initialiser and the Parser

Extensions

There are some build in extensions to make your live easier.

NSBundle

You can get the version as struct Version of a NSBundle if set in the bunlde info.plist like:

let bundle = NSBundle(forClass: self.dynamicType)
if let version = bundle.version
{
	// ...
}

IntegerLiteralConvertible

Converts an Integer to a Version struct. You can use this only to represent major versions.

Custom extensions

Create your own extensions or Version representations by creating struct / object that conforms to SemanticVersion. Have a look at the extensions or the Version implementation for more information.

semanticversioning's People

Contributors

alexanderney avatar yoneapp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.