Skip to content

Commit 4f8237d

Browse files
Ian Partridgedjones6
authored andcommitted
Support Swift 5 (#39)
1 parent 86658aa commit 4f8237d

7 files changed

Lines changed: 102 additions & 6 deletions

File tree

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.3
1+
5.0

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ matrix:
2525
dist: xenial
2626
sudo: required
2727
services: docker
28-
env: DOCKER_IMAGE=swift:4.2.3
28+
env: DOCKER_IMAGE=swift:4.2.4 SWIFT_SNAPSHOT=4.2.4
2929
- os: linux
3030
dist: xenial
3131
sudo: required
3232
services: docker
33-
env: DOCKER_IMAGE=swift:4.2.3 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
33+
env: DOCKER_IMAGE=swift:5.0-xenial
3434
- os: linux
3535
dist: xenial
3636
sudo: required
3737
services: docker
38-
env: DOCKER_IMAGE=ubuntu:18.04
38+
env: DOCKER_IMAGE=swift:5.0 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
3939
- os: osx
4040
osx_image: xcode9.2
4141
sudo: required
@@ -47,8 +47,12 @@ matrix:
4747
- os: osx
4848
osx_image: xcode10.1
4949
sudo: required
50+
env: SWIFT_SNAPSHOT=4.2.1
5051
- os: osx
51-
osx_image: xcode10.1
52+
osx_image: xcode10.2
53+
sudo: required
54+
- os: osx
55+
osx_image: xcode10.2
5256
sudo: required
5357
env: SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
5458

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:5.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

Package@swift-4.0.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:4.0
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "KituraContracts",
8+
products: [
9+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
10+
.library(
11+
name: "KituraContracts",
12+
targets: ["KituraContracts"]),
13+
],
14+
dependencies: [
15+
// Dependencies declare other packages that this package depends on.
16+
.package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"),
17+
],
18+
targets: [
19+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
21+
.target(
22+
name: "KituraContracts",
23+
dependencies: ["LoggerAPI"]),
24+
.testTarget(
25+
name: "KituraContractsTests",
26+
dependencies: ["KituraContracts"]),
27+
]
28+
)

Package@swift-4.1.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:4.0
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "KituraContracts",
8+
products: [
9+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
10+
.library(
11+
name: "KituraContracts",
12+
targets: ["KituraContracts"]),
13+
],
14+
dependencies: [
15+
// Dependencies declare other packages that this package depends on.
16+
.package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"),
17+
],
18+
targets: [
19+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
21+
.target(
22+
name: "KituraContracts",
23+
dependencies: ["LoggerAPI"]),
24+
.testTarget(
25+
name: "KituraContractsTests",
26+
dependencies: ["KituraContracts"]),
27+
]
28+
)

Package@swift-4.2.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:4.2
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "KituraContracts",
8+
products: [
9+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
10+
.library(
11+
name: "KituraContracts",
12+
targets: ["KituraContracts"]),
13+
],
14+
dependencies: [
15+
// Dependencies declare other packages that this package depends on.
16+
.package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"),
17+
],
18+
targets: [
19+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
21+
.target(
22+
name: "KituraContracts",
23+
dependencies: ["LoggerAPI"]),
24+
.testTarget(
25+
name: "KituraContractsTests",
26+
dependencies: ["KituraContracts"]),
27+
]
28+
)

Sources/KituraContracts/Contracts.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,18 @@ public struct Ordering: Codable {
10211021

10221022
// Function to extract the String value from the Order enum case
10231023
private func extractValue(_ value: String) throws -> String {
1024+
#if swift(>=4.2)
1025+
guard var startIndex = value.firstIndex(of: "("),
1026+
let endIndex = value.firstIndex(of: ")") else {
1027+
throw QueryParamsError.invalidValue
1028+
}
1029+
#else
10241030
guard var startIndex = value.index(of: "("),
10251031
let endIndex = value.index(of: ")") else {
10261032
throw QueryParamsError.invalidValue
10271033
}
1034+
#endif
1035+
10281036
startIndex = value.index(startIndex, offsetBy: 1)
10291037
let extractedValue = value[startIndex..<endIndex]
10301038
return String(extractedValue)

0 commit comments

Comments
 (0)