Skip to content

Commit

Permalink
Support Swift 5 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpartridge authored and djones6 committed Apr 4, 2019
1 parent 86658aa commit 4f8237d
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.3
5.0
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ matrix:
dist: xenial
sudo: required
services: docker
env: DOCKER_IMAGE=swift:4.2.3
env: DOCKER_IMAGE=swift:4.2.4 SWIFT_SNAPSHOT=4.2.4
- os: linux
dist: xenial
sudo: required
services: docker
env: DOCKER_IMAGE=swift:4.2.3 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
env: DOCKER_IMAGE=swift:5.0-xenial
- os: linux
dist: xenial
sudo: required
services: docker
env: DOCKER_IMAGE=ubuntu:18.04
env: DOCKER_IMAGE=swift:5.0 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
- os: osx
osx_image: xcode9.2
sudo: required
Expand All @@ -47,8 +47,12 @@ matrix:
- os: osx
osx_image: xcode10.1
sudo: required
env: SWIFT_SNAPSHOT=4.2.1
- os: osx
osx_image: xcode10.1
osx_image: xcode10.2
sudo: required
- os: osx
osx_image: xcode10.2
sudo: required
env: SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.0
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
28 changes: 28 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "KituraContracts",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "KituraContracts",
targets: ["KituraContracts"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "KituraContracts",
dependencies: ["LoggerAPI"]),
.testTarget(
name: "KituraContractsTests",
dependencies: ["KituraContracts"]),
]
)
28 changes: 28 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "KituraContracts",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "KituraContracts",
targets: ["KituraContracts"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "KituraContracts",
dependencies: ["LoggerAPI"]),
.testTarget(
name: "KituraContractsTests",
dependencies: ["KituraContracts"]),
]
)
28 changes: 28 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "KituraContracts",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "KituraContracts",
targets: ["KituraContracts"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "KituraContracts",
dependencies: ["LoggerAPI"]),
.testTarget(
name: "KituraContractsTests",
dependencies: ["KituraContracts"]),
]
)
8 changes: 8 additions & 0 deletions Sources/KituraContracts/Contracts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1021,10 +1021,18 @@ public struct Ordering: Codable {

// Function to extract the String value from the Order enum case
private func extractValue(_ value: String) throws -> String {
#if swift(>=4.2)
guard var startIndex = value.firstIndex(of: "("),
let endIndex = value.firstIndex(of: ")") else {
throw QueryParamsError.invalidValue
}
#else
guard var startIndex = value.index(of: "("),
let endIndex = value.index(of: ")") else {
throw QueryParamsError.invalidValue
}
#endif

startIndex = value.index(startIndex, offsetBy: 1)
let extractedValue = value[startIndex..<endIndex]
return String(extractedValue)
Expand Down

0 comments on commit 4f8237d

Please sign in to comment.