Skip to content

Commit

Permalink
Merge pull request #24 from AlexanderNey/swiftpm-support
Browse files Browse the repository at this point in the history
Swiftpm support, Bump version to 3.0
  • Loading branch information
AlexanderNey authored Mar 29, 2020
2 parents 364a16e + 0f5feb0 commit 1c9c797
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 892 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Xcode
#
build/
.build
*.pbxuser
!default.pbxuser
*.mode1v3
Expand All @@ -16,6 +16,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
.swiftpm

# CocoaPods
#
Expand Down
24 changes: 14 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
osx_image: xcode10
language: objective-c
language: swift
os: osx
osx_image: xcode11.3

env:
- DESTINATION="platform=iOS Simulator,name=iPhone 6,OS=9.0"
- DESTINATION="platform=iOS Simulator,name=iPhone 6,OS=10.0"
- DESTINATION="platform=iOS Simulator,name=iPhone 6,OS=11.1"
- DESTINATION="platform=iOS Simulator,name=iPhone 6,OS=12.0"
jobs:
include:
- name: "TV OS"
env: DESTINATION="platform=tvOS Simulator,OS=11.0,name=Apple TV"
- name: "iOS"
env: DESTINATION="platform=iOS Simulator,OS=11.0.1,name=iPhone X"
- name: "Mac"
env: DESTINATION="platform=macOS,arch=x86_64"
script:
- xcodebuild clean build -project SemanticVersioning.xcodeproj -scheme "SemanticVersioning" -destination "$DESTINATION" -enableCodeCoverage YES test
after_success:
- bash <(curl -s https://codecov.io/bash) -J "$DESTINATION" -t cee9d255-69c0-455d-83d4-eb28f696a299
- swift package generate-xcodeproj
- echo "build for $DESTINATION"
- xcodebuild clean build -project SemanticVersioning.xcodeproj -scheme "SemanticVersioning-Package" -destination "$DESTINATION" -enableCodeCoverage YES test
26 changes: 26 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SemanticVersioning",
platforms: [
.macOS(.v10_13), .iOS(.v11), .tvOS(.v11), .watchOS(.v4)
],
products: [
.library(name: "SemanticVersioning", targets: ["SemanticVersioning"]),
],
dependencies: [],
targets: [
.target(
name: "SemanticVersioning",
dependencies: [],
path: "Source"),
.testTarget(
name: "SemanticVersioningTests",
dependencies: ["SemanticVersioning"],
path: "Tests"),
],
swiftLanguageVersions: [.v5]
)
70 changes: 15 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![Platform](https://img.shields.io/cocoapods/p/SemanticVersioning.svg)
![License](https://img.shields.io/cocoapods/l/SemanticVersioning.svg)
![Travis](https://img.shields.io/travis/AlexanderNey/SemanticVersioning.svg)
[![Swift Version](https://img.shields.io/badge/Swift-3.0-F16D39.svg?style=flat)](https://developer.apple.com/swift)
[![Swift Version](https://img.shields.io/badge/Swift-5.0-F16D39.svg?style=flat)](https://developer.apple.com/swift)
[![codecov](https://codecov.io/gh/AlexanderNey/SemanticVersioning/branch/master/graph/badge.svg)](https://codecov.io/gh/AlexanderNey/SemanticVersioning)

Semantic Versioning implementation in Swift!
Expand All @@ -20,21 +20,24 @@ Use the struct `Version` to represent a version according to the [Semantic Versi

### Requirements

- iOS 8.0+ / Mac OS X 10.9+
- Xcode 10.0+
- Swift 4.2
- 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](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) on how to use this library with Swift PM.

### CocoaPods
See installation instructions for [CocoaPods](http://cocoapods.org) if not already installed

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

```ruby
platform :ios, '8.0'
platform :ios, '11.0'
use_frameworks!

pod 'SemanticVersioning'
Expand Down Expand Up @@ -105,45 +108,33 @@ for identifier in version.buildMetadataIdentifier
Conforms to Printable so you can simply get a String representation by accessing the description property

```Swift
println(version)
print(version)
// OR
let stringRepresentation = version.description
```

mutability / immutability


### Comparsion
### Comparison

The default operators for comparsion are implemented
The default operators for comparison are implemented
`<` , `<=` , `>` ,`>=` ,`==` , `!=`
This will comapre major, minor, patch and the prerelease identifiers according to the [Semantic Versioning Sepcification 2.0.0](http://semver.org/spec/v2.0.0.html)
This will compare major, minor, patch and the prerelease identifiers according to the [Semantic Versioning Specification 2.0.0](http://semver.org/spec/v2.0.0.html)


## Parser

The implementation includes a full-fledged component ot parse String representation of a version. Please have a look at the tests and the soruce of `SemanticVersioningParser` for now 😉
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 libary includes a suite of tests showing how to use the different initialiser and the Parser
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.

### NSOperatingSystemVersion

`NSOperatingSystemVersion` conforms to `SemanticVersion` so it can be compared with all other structs / objects that conform to the same protocol (e.g. `Version`).

So you can check the current system Version like this (on iOS 8+):
```Swift
let systemVersion = NSProcessInfo.processInfo().operatingSystemVersion
if systemVersion < Version(major: 8)
{
// ...
}
```

### NSBundle

Expand All @@ -157,42 +148,11 @@ if let version = bundle.version
}
```

### UIDevice

You can get the operating system version from a `UIDevice` object by using `operatingSystemVersion` which returns a `Version` representation of `systemVersion`.

```Swift
let systemVersion = UIDevice.currentDevice().operatingSystemVersion
if systemVersion < Version(major: 8)
{
// ...
}

```

### IntegerLiteralConvertible

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

```Swift
let systemVersion = NSProcessInfo.processInfo().operatingSystemVersion
if systemVersion < 8
{
// ...
}
```

Reducing the version's minor and major value to a `Float` is also possible. Use this with ⚠️**caution**⚠️ as the `Float` representation could lead to accuracy loss of the minor value (that is represented as fractional digits). I would not reccommend to compare with `==` but `<` , `<=` , `>` ,`>=` should be useful.

```Swift
let systemVersion = NSProcessInfo.processInfo().operatingSystemVersion
if systemVersion.floatValue() < 8.1
{
// ...
}
```


## Custom extensions

Create your own extensions or Version representations by creating struct / object that conforms to `SemanticVersioning`. Have a look at the extensions or the `Version` implementation for more information.
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.
13 changes: 6 additions & 7 deletions SemanticVersioning.podspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
Pod::Spec.new do |s|
s.name = 'SemanticVersioning'
s.version = '2.0.1'
s.version = '3.0.0'
s.license = { :type => "MIT" }
s.summary = 'Elegant Semantic Versioning in Swift 4'
s.summary = 'Elegant Semantic Versioning in Swift 5'
s.homepage = 'https://github.com/AlexanderNey/SemanticVersioning'
s.social_media_url = 'http://twitter.com/Ajax64'
s.authors = { 'Alexander Ney' => '[email protected]' }
s.source = { :git => 'https://github.com/AlexanderNey/SemanticVersioning.git', :branch => 'master', :tag => "v#{s.version}" }
s.requires_arc = true
s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '10.0'
s.osx.deployment_target = '10.9'
s.swift_version = '4.0'
s.ios.deployment_target = '11.0'
s.tvos.deployment_target = '11.0'
s.osx.deployment_target = '10.13'
s.swift_version = '5.0'
s.source_files = 'Source/*.swift'

end
Loading

0 comments on commit 1c9c797

Please sign in to comment.