Latest 1.1.1
Homepage https://github.com/glwithu06/Semver.swift
License MIT
Platforms ios 8.0, osx 10.11, tvos 9.0, watchos 2.0
Frameworks Foundation
Authors

Swift
CocoaPods


Platform


Build Status


Codecov

Semantic Versioning

Semantic Versioning implementation in Swift.
Semver represent a semantic version according to the Semantic Versioning Specification.

Requirements

  • Xcode 10.1+
  • Swift 4.2
  • iOS 8
  • macOS 10.11
  • tvOS 9.0
  • watchOS 2.0

Installation

Semver doesn’t contain any external dependencies.
These are currently support options:

Cocoapods

# Podfile
user_framework!
target 'YOUR_TARGET_NAME' do
    pod 'Semver.swift'
end

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

$ pod install

Swift Package Manager

Create a Package.swift file.

// swift-tools-version:4.2

import PackageDescription

let package = Package(
  name: "NAME",
  dependencies: [
    .package(url: "https://github.com/glwithu06/Semver.swift.git", from: "SEMVER_TAG")
  ],
  targets: [
    .target(name: "NAME", dependencies: ["Semver"])
  ]
)

Replace SEMVER_TAG and then type:

$ swift build

Usage

Create

Semver can be instantiated directly:

let version = Semver(major: 1, minor: 23, patch: 45, prereleaseIdentifiers: ["rc", "1"], buildMetadataIdentifiers: ["B001"])

minor, patch are optional parameters default to "0".

prereleaseIdentifiers, buildMetadataIdentifiers are optional parameters default to [].

Parse

You can create Semver from String.

let version = try Semver("1.23.45-rc.1+B001")

or from Numeric.

let version = try Semver(1.23)
let version = try Semver(10)

If the version is invalid, it throws a ParsingError.

Extensions

Semver conforms to ExpressibleByStringLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral.

It can convert a String to Semver.

let version: Semver = "1.23.45-rc.1+B001"

or Numeric to Semver.

let version: Semver = 1
let version: Semver = 1.23

⚠️ If the version is invalid, Semver represents "0.0.0". It doesn’t throw any errors.

Compare

The default operators for comparsion are implemented(< , <= , > ,>= ,== , !=).

This will comapre major, minor, patch and the prerelease identifiers according to the Semantic Versioning Specification.

Contribution

Any pull requests and bug reports are welcome!

Feel free to make a pull request.

Latest podspec

{
    "name": "Semver.swift",
    "version": "1.1.1",
    "license": "MIT",
    "summary": "Semantic Versioning implementation in Swift",
    "homepage": "https://github.com/glwithu06/Semver.swift",
    "authors": {
        "Nate Kim": "glwithu[email protected]"
    },
    "frameworks": "Foundation",
    "source": {
        "git": "https://github.com/glwithu06/Semver.swift.git",
        "tag": "1.1.1"
    },
    "source_files": "Sources/*.swift",
    "platforms": {
        "ios": "8.0",
        "osx": "10.11",
        "tvos": "9.0",
        "watchos": "2.0"
    }
}

Pin It on Pinterest

Share This