Skip to content

Commit 862a8f8

Browse files
authored
Merge pull request #268 from chn-lyzhi/develop-Swift5
Support Swift 5.0
2 parents f14b5eb + 5f4b96b commit 862a8f8

21 files changed

+39
-108
lines changed

.gitmodules

-3
This file was deleted.

.swift-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0
1+
5.0

.travis.yml

+5-14
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,32 @@ env:
55
matrix:
66
include:
77
- &podspec
8+
name: CocoaPods Lint
89
os: osx
910
language: objective-c
1011
osx_image: xcode10.2
1112
script:
1213
- pod lib lint --allow-warnings
1314
- &xcode
15+
name: Xcode 10.2 / Swift 5.0
1416
os: osx
1517
language: objective-c
16-
osx_image: xcode9.2
18+
osx_image: xcode10.2
1719
script:
1820
- set -o pipefail
1921
- xcodebuild build-for-testing test-without-building -workspace APIKit.xcworkspace -scheme APIKit -configuration Release ENABLE_TESTABILITY=YES | xcpretty -c
2022
- xcodebuild build-for-testing test-without-building -workspace APIKit.xcworkspace -scheme APIKit -configuration Release -sdk iphonesimulator -destination "name=iPhone 6s" ENABLE_TESTABILITY=YES | xcpretty -c
2123
- xcodebuild build-for-testing test-without-building -workspace APIKit.xcworkspace -scheme APIKit -configuration Release -sdk appletvsimulator -destination "name=Apple TV" ENABLE_TESTABILITY=YES | xcpretty -c
2224
after_success:
2325
- bash <(curl -s https://codecov.io/bash)
24-
- <<: *xcode
25-
osx_image: xcode9.4
26-
- <<: *xcode
27-
osx_image: xcode10.1
28-
- <<: *xcode
29-
osx_image: xcode10.2
3026
- &swiftpm
27+
name: SwiftPM / Darwin / Swift 5.0
3128
os: osx
3229
language: generic
33-
osx_image: xcode9.2
30+
osx_image: xcode10.2
3431
script:
3532
- swift build
3633
- swift test
37-
- <<: *swiftpm
38-
osx_image: xcode9.4
39-
- <<: *swiftpm
40-
osx_image: xcode10.1
41-
- <<: *swiftpm
42-
osx_image: xcode10.2
4334

4435
notifications:
4536
email: false

APIKit.podspec

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "APIKit"
3-
s.version = "4.1.0"
3+
s.version = "5.0.0"
44
s.summary = "Type-safe networking abstraction layer that associates request type with response type."
55
s.homepage = "https://github.com/ishkawa/APIKit"
66

@@ -23,7 +23,7 @@ Pod::Spec.new do |s|
2323
:tag => "#{s.version}",
2424
}
2525

26-
s.swift_version = "4.0"
26+
s.swift_version = "5.0"
2727

2828
s.license = {
2929
:type => "MIT",
@@ -34,6 +34,4 @@ Pod::Spec.new do |s|
3434
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3535
LICENSE
3636
}
37-
38-
s.dependency "Result", "~> 4.0"
3937
end

APIKit.xcodeproj/project.pbxproj

+6-12
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
141F12201C1C9ABE0026D415 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD5115241B1FFBA900514240 /* Result.framework */; };
11-
141F12311C1C9AC70026D415 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD5115241B1FFBA900514240 /* Result.framework */; };
12-
141F12361C1C9AC70026D415 /* Result.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = CD5115241B1FFBA900514240 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1310
7F698E501D9D680C00F1561D /* FormURLEncodedBodyParametersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F698E3C1D9D680C00F1561D /* FormURLEncodedBodyParametersTests.swift */; };
1411
7F698E511D9D680C00F1561D /* JSONBodyParametersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F698E3D1D9D680C00F1561D /* JSONBodyParametersTests.swift */; };
1512
7F698E521D9D680C00F1561D /* MultipartFormDataParametersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F698E3E1D9D680C00F1561D /* MultipartFormDataParametersTests.swift */; };
@@ -72,7 +69,6 @@
7269
dstPath = "";
7370
dstSubfolderSpec = 10;
7471
files = (
75-
141F12361C1C9AC70026D415 /* Result.framework in Copy Frameworks */,
7672
);
7773
name = "Copy Frameworks";
7874
runOnlyForDeploymentPostprocessing = 0;
@@ -129,7 +125,6 @@
129125
7F7048F21D9D8A1F003C99F6 /* URLEncodedSerialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = URLEncodedSerialization.swift; path = Sources/APIKit/Serializations/URLEncodedSerialization.swift; sourceTree = SOURCE_ROOT; };
130126
7F8ECDFD1B6A799E00234E04 /* Demo.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Demo.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
131127
7FA1690C1D9D8C80006C982B /* HTTPStub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPStub.swift; sourceTree = "<group>"; };
132-
CD5115241B1FFBA900514240 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Result.framework; sourceTree = BUILT_PRODUCTS_DIR; };
133128
ECA831471DE4DDBF004EB1B5 /* ProtobufDataParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProtobufDataParser.swift; path = Sources/APIKit/DataParser/ProtobufDataParser.swift; sourceTree = SOURCE_ROOT; };
134129
ECA831491DE4DEBE004EB1B5 /* ProtobufDataParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProtobufDataParserTests.swift; sourceTree = "<group>"; };
135130
ECA8314B1DE4E677004EB1B5 /* ProtobufBodyParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProtobufBodyParameters.swift; path = Sources/APIKit/BodyParameters/ProtobufBodyParameters.swift; sourceTree = SOURCE_ROOT; };
@@ -141,15 +136,13 @@
141136
isa = PBXFrameworksBuildPhase;
142137
buildActionMask = 2147483647;
143138
files = (
144-
141F12201C1C9ABE0026D415 /* Result.framework in Frameworks */,
145139
);
146140
runOnlyForDeploymentPostprocessing = 0;
147141
};
148142
141F12301C1C9AC70026D415 /* Frameworks */ = {
149143
isa = PBXFrameworksBuildPhase;
150144
buildActionMask = 2147483647;
151145
files = (
152-
141F12311C1C9AC70026D415 /* Result.framework in Frameworks */,
153146
);
154147
runOnlyForDeploymentPostprocessing = 0;
155148
};
@@ -308,7 +301,6 @@
308301
children = (
309302
7F7048C61D9D89BE003C99F6 /* APIKit.h */,
310303
7F7048C91D9D89BE003C99F6 /* Info.plist */,
311-
CD5115241B1FFBA900514240 /* Result.framework */,
312304
);
313305
name = "Supporting Files";
314306
sourceTree = "<group>";
@@ -402,7 +394,7 @@
402394
isa = PBXProject;
403395
attributes = {
404396
LastSwiftUpdateCheck = 0730;
405-
LastUpgradeCheck = 0930;
397+
LastUpgradeCheck = 1020;
406398
ORGANIZATIONNAME = "Yosuke Ishikawa";
407399
TargetAttributes = {
408400
141F12161C1C9ABE0026D415 = {
@@ -415,7 +407,7 @@
415407
};
416408
buildConfigurationList = 7F45FCD71A94D02C006863BB /* Build configuration list for PBXProject "APIKit" */;
417409
compatibilityVersion = "Xcode 3.2";
418-
developmentRegion = English;
410+
developmentRegion = en;
419411
hasScannedForEncodings = 0;
420412
knownRegions = (
421413
en,
@@ -562,6 +554,7 @@
562554
isa = XCBuildConfiguration;
563555
baseConfigurationReference = 141F12101C1C96820026D415 /* Debug.xcconfig */;
564556
buildSettings = {
557+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
565558
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
566559
CLANG_WARN_COMMA = YES;
567560
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
@@ -575,14 +568,15 @@
575568
ENABLE_TESTABILITY = YES;
576569
GCC_NO_COMMON_BLOCKS = YES;
577570
ONLY_ACTIVE_ARCH = YES;
578-
SWIFT_VERSION = 4.0;
571+
SWIFT_VERSION = 5.0;
579572
};
580573
name = Debug;
581574
};
582575
7F45FCF21A94D02C006863BB /* Release */ = {
583576
isa = XCBuildConfiguration;
584577
baseConfigurationReference = 141F12111C1C96820026D415 /* Release.xcconfig */;
585578
buildSettings = {
579+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
586580
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
587581
CLANG_WARN_COMMA = YES;
588582
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
@@ -594,7 +588,7 @@
594588
CLANG_WARN_STRICT_PROTOTYPES = YES;
595589
CLANG_WARN_SUSPICIOUS_MOVE = YES;
596590
GCC_NO_COMMON_BLOCKS = YES;
597-
SWIFT_VERSION = 4.0;
591+
SWIFT_VERSION = 5.0;
598592
};
599593
name = Release;
600594
};

APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

APIKit.xcworkspace/contents.xcworkspacedata

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cartfile

-1
This file was deleted.

Cartfile.resolved

-1
This file was deleted.

Carthage/Checkouts/Result

-1
This file was deleted.

Package.resolved

-16
This file was deleted.

Package.swift

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:5.0
22
import PackageDescription
33

44
let package = Package(
55
name: "APIKit",
6+
platforms: [
7+
.macOS(.v10_10), .iOS(.v8), .tvOS(.v9), .watchOS(.v2)
8+
],
69
products: [
710
.library(name: "APIKit", targets: ["APIKit"]),
811
],
9-
dependencies: [
10-
.package(url: "https://github.com/antitypical/Result.git", from: "4.0.0"),
11-
],
12+
dependencies: [],
1213
targets: [
1314
.target(
1415
name: "APIKit",
15-
dependencies: ["Result"],
16+
dependencies: [],
1617
exclude: ["BodyParameters/AbstractInputStream.m"]
1718
),
1819
.testTarget(
1920
name: "APIKitTests",
2021
dependencies: ["APIKit"]
2122
),
2223
],
23-
swiftLanguageVersions: [4]
24+
swiftLanguageVersions: [.v5]
2425
)

[email protected]

-24
This file was deleted.

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,30 @@ Session.send(request) { result in
3030

3131
## Requirements
3232

33-
- Swift 3.0 or later
33+
- Swift 5.0 or later
3434
- iOS 8.0 or later
3535
- Mac OS 10.10 or later
3636
- watchOS 2.0 or later
3737
- tvOS 9.0 or later
3838

3939
If you use Swift 2.2 or 2.3, try [APIKit 2.0.5](https://github.com/ishkawa/APIKit/tree/2.0.5).
4040

41+
If you use Swift 4.2 or before, try [APIKit 4.1.0](https://github.com/ishkawa/APIKit/tree/4.1.0).
42+
4143
## Installation
4244

4345
#### [Carthage](https://github.com/Carthage/Carthage)
4446

45-
- Insert `github "ishkawa/APIKit" ~> 3.1` to your Cartfile.
47+
- Insert `github "ishkawa/APIKit" ~> 5.0` to your Cartfile.
4648
- Run `carthage update`.
4749
- Link your app with `APIKit.framework` and `Result.framework` in `Carthage/Build`.
4850

4951
#### [CocoaPods](https://github.com/cocoapods/cocoapods)
5052

51-
- Insert `pod 'APIKit', '~> 3.1'` to your Podfile.
53+
- Insert `pod 'APIKit', '~> 5.0'` to your Podfile.
5254
- Run `pod install`.
5355

54-
Note: CocoaPods 1.1.0 is required to install APIKit 3.
56+
Note: CocoaPods 1.4.0 is required to install APIKit 5.
5557

5658
## Documentation
5759

Sources/APIKit/BodyParameters/MultipartFormDataBodyParameters.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public struct MultipartFormDataBodyParameters: BodyParameters {
5858

5959
public extension MultipartFormDataBodyParameters {
6060
/// Part represents single part of multipart/form-data.
61-
public struct Part {
61+
struct Part {
6262
public enum Error: Swift.Error {
6363
case illegalValue(Any)
6464
case illegalFileURL(URL)

Sources/APIKit/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>4.1.0</string>
18+
<string>5.0.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Sources/APIKit/Request.swift

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Foundation
2-
import Result
32

43
/// `Request` protocol represents a request for Web API.
54
/// Following 5 items must be implemented.
@@ -62,39 +61,39 @@ public protocol Request {
6261
}
6362

6463
public extension Request {
65-
public var parameters: Any? {
64+
var parameters: Any? {
6665
return nil
6766
}
6867

69-
public var queryParameters: [String: Any]? {
68+
var queryParameters: [String: Any]? {
7069
guard let parameters = parameters as? [String: Any], method.prefersQueryParameters else {
7170
return nil
7271
}
7372

7473
return parameters
7574
}
7675

77-
public var bodyParameters: BodyParameters? {
76+
var bodyParameters: BodyParameters? {
7877
guard let parameters = parameters, !method.prefersQueryParameters else {
7978
return nil
8079
}
8180

8281
return JSONBodyParameters(JSONObject: parameters)
8382
}
8483

85-
public var headerFields: [String: String] {
84+
var headerFields: [String: String] {
8685
return [:]
8786
}
8887

89-
public var dataParser: DataParser {
88+
var dataParser: DataParser {
9089
return JSONDataParser(readingOptions: [])
9190
}
9291

93-
public func intercept(urlRequest: URLRequest) throws -> URLRequest {
92+
func intercept(urlRequest: URLRequest) throws -> URLRequest {
9493
return urlRequest
9594
}
9695

97-
public func intercept(object: Any, urlResponse: HTTPURLResponse) throws -> Any {
96+
func intercept(object: Any, urlResponse: HTTPURLResponse) throws -> Any {
9897
guard 200..<300 ~= urlResponse.statusCode else {
9998
throw ResponseError.unacceptableStatusCode(urlResponse.statusCode)
10099
}
@@ -103,7 +102,7 @@ public extension Request {
103102

104103
/// Builds `URLRequest` from properties of `self`.
105104
/// - Throws: `RequestError`, `Error`
106-
public func buildURLRequest() throws -> URLRequest {
105+
func buildURLRequest() throws -> URLRequest {
107106
let url = path.isEmpty ? baseURL : baseURL.appendingPathComponent(path)
108107
guard var components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
109108
throw RequestError.invalidBaseURL(baseURL)
@@ -140,7 +139,7 @@ public extension Request {
140139

141140
/// Builds `Response` from response `Data`.
142141
/// - Throws: `ResponseError`, `Error`
143-
public func parse(data: Data, urlResponse: HTTPURLResponse) throws -> Response {
142+
func parse(data: Data, urlResponse: HTTPURLResponse) throws -> Response {
144143
let parsedObject = try dataParser.parse(data: data)
145144
let passedObject = try intercept(object: parsedObject, urlResponse: urlResponse)
146145
return try response(from: passedObject, urlResponse: urlResponse)

0 commit comments

Comments
 (0)