diff --git a/.gitmodules b/.gitmodules index 00f2c4d7..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "Carthage/Checkouts/Result"] - path = Carthage/Checkouts/Result - url = https://github.com/antitypical/Result.git diff --git a/APIKit.xcodeproj/project.pbxproj b/APIKit.xcodeproj/project.pbxproj index 0e672020..6f193f5d 100644 --- a/APIKit.xcodeproj/project.pbxproj +++ b/APIKit.xcodeproj/project.pbxproj @@ -7,9 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 141F12201C1C9ABE0026D415 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD5115241B1FFBA900514240 /* Result.framework */; }; - 141F12311C1C9AC70026D415 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD5115241B1FFBA900514240 /* Result.framework */; }; - 141F12361C1C9AC70026D415 /* Result.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = CD5115241B1FFBA900514240 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 7F698E501D9D680C00F1561D /* FormURLEncodedBodyParametersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F698E3C1D9D680C00F1561D /* FormURLEncodedBodyParametersTests.swift */; }; 7F698E511D9D680C00F1561D /* JSONBodyParametersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F698E3D1D9D680C00F1561D /* JSONBodyParametersTests.swift */; }; 7F698E521D9D680C00F1561D /* MultipartFormDataParametersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F698E3E1D9D680C00F1561D /* MultipartFormDataParametersTests.swift */; }; @@ -56,7 +53,7 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 7F4A73AC1CA839AE002554B1 /* PBXContainerItemProxy */ = { + BDFB151A2253060A00D8C94B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 7F45FCD41A94D02C006863BB /* Project object */; proxyType = 1; @@ -72,7 +69,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 141F12361C1C9AC70026D415 /* Result.framework in Copy Frameworks */, ); name = "Copy Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -129,7 +125,6 @@ 7F7048F21D9D8A1F003C99F6 /* URLEncodedSerialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = URLEncodedSerialization.swift; path = Sources/APIKit/Serializations/URLEncodedSerialization.swift; sourceTree = SOURCE_ROOT; }; 7F8ECDFD1B6A799E00234E04 /* Demo.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Demo.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 7FA1690C1D9D8C80006C982B /* HTTPStub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPStub.swift; sourceTree = ""; }; - CD5115241B1FFBA900514240 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Result.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ECA831471DE4DDBF004EB1B5 /* ProtobufDataParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProtobufDataParser.swift; path = Sources/APIKit/DataParser/ProtobufDataParser.swift; sourceTree = SOURCE_ROOT; }; ECA831491DE4DEBE004EB1B5 /* ProtobufDataParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProtobufDataParserTests.swift; sourceTree = ""; }; ECA8314B1DE4E677004EB1B5 /* ProtobufBodyParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProtobufBodyParameters.swift; path = Sources/APIKit/BodyParameters/ProtobufBodyParameters.swift; sourceTree = SOURCE_ROOT; }; @@ -141,7 +136,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 141F12201C1C9ABE0026D415 /* Result.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -149,7 +143,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 141F12311C1C9AC70026D415 /* Result.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -308,7 +301,6 @@ children = ( 7F7048C61D9D89BE003C99F6 /* APIKit.h */, 7F7048C91D9D89BE003C99F6 /* Info.plist */, - CD5115241B1FFBA900514240 /* Result.framework */, ); name = "Supporting Files"; sourceTree = ""; @@ -388,7 +380,7 @@ buildRules = ( ); dependencies = ( - 7F4A73AD1CA839AE002554B1 /* PBXTargetDependency */, + BDFB151B2253060A00D8C94B /* PBXTargetDependency */, ); name = Tests; productName = APIKitTests; @@ -402,7 +394,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yosuke Ishikawa"; TargetAttributes = { 141F12161C1C9ABE0026D415 = { @@ -415,7 +407,7 @@ }; buildConfigurationList = 7F45FCD71A94D02C006863BB /* Build configuration list for PBXProject "APIKit" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -509,10 +501,10 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 7F4A73AD1CA839AE002554B1 /* PBXTargetDependency */ = { + BDFB151B2253060A00D8C94B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 141F12161C1C9ABE0026D415 /* APIKit */; - targetProxy = 7F4A73AC1CA839AE002554B1 /* PBXContainerItemProxy */; + targetProxy = BDFB151A2253060A00D8C94B /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -524,8 +516,10 @@ CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -536,8 +530,10 @@ CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -546,6 +542,7 @@ baseConfigurationReference = 141F12401C1C9EA30026D415 /* Tests.xcconfig */; buildSettings = { INFOPLIST_FILE = Tests/APIKitTests/Info.plist; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -555,6 +552,7 @@ buildSettings = { INFOPLIST_FILE = Tests/APIKitTests/Info.plist; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -562,6 +560,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 141F12101C1C96820026D415 /* Debug.xcconfig */; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; @@ -583,6 +582,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 141F12111C1C96820026D415 /* Release.xcconfig */; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; diff --git a/APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme b/APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme index 8125e06b..762479b4 100644 --- a/APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme +++ b/APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme @@ -1,6 +1,6 @@ - - diff --git a/Cartfile b/Cartfile deleted file mode 100644 index e9bc3ad0..00000000 --- a/Cartfile +++ /dev/null @@ -1 +0,0 @@ -github "antitypical/Result" ~> 4.0 diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index 23aa9709..00000000 --- a/Cartfile.resolved +++ /dev/null @@ -1 +0,0 @@ -github "antitypical/Result" "4.0.0" diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result deleted file mode 160000 index 8fc088dc..00000000 --- a/Carthage/Checkouts/Result +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8fc088dcf72802801efeecba76ea8fb041fb773d diff --git a/README.md b/README.md index 6dd793e3..f9036697 100644 --- a/README.md +++ b/README.md @@ -30,28 +30,30 @@ Session.send(request) { result in ## Requirements -- Swift 3.0 or later +- Swift 5.0 or later - iOS 8.0 or later -- Mac OS 10.10 or later +- Mac OS 10.11 or later - watchOS 2.0 or later - tvOS 9.0 or later If you use Swift 2.2 or 2.3, try [APIKit 2.0.5](https://github.com/ishkawa/APIKit/tree/2.0.5). +If you use Swift 4.2 or before, try [APIKit 4.1.0](https://github.com/ishkawa/APIKit/tree/release/4.1.0). + ## Installation #### [Carthage](https://github.com/Carthage/Carthage) -- Insert `github "ishkawa/APIKit" ~> 3.1` to your Cartfile. +- Insert `github "ishkawa/APIKit" ~> 5.0` to your Cartfile. - Run `carthage update`. - Link your app with `APIKit.framework` and `Result.framework` in `Carthage/Build`. #### [CocoaPods](https://github.com/cocoapods/cocoapods) -- Insert `pod 'APIKit', '~> 3.1'` to your Podfile. +- Insert `pod 'APIKit', '~> 5.0'` to your Podfile. - Run `pod install`. -Note: CocoaPods 1.1.0 is required to install APIKit 3. +Note: CocoaPods 1.1.0 is required to install APIKit 5. ## Documentation diff --git a/Sources/APIKit/BodyParameters/MultipartFormDataBodyParameters.swift b/Sources/APIKit/BodyParameters/MultipartFormDataBodyParameters.swift index 0b1e2d2d..d1337978 100644 --- a/Sources/APIKit/BodyParameters/MultipartFormDataBodyParameters.swift +++ b/Sources/APIKit/BodyParameters/MultipartFormDataBodyParameters.swift @@ -58,7 +58,7 @@ public struct MultipartFormDataBodyParameters: BodyParameters { public extension MultipartFormDataBodyParameters { /// Part represents single part of multipart/form-data. - public struct Part { + struct Part { public enum Error: Swift.Error { case illegalValue(Any) case illegalFileURL(URL) diff --git a/Sources/APIKit/Info.plist b/Sources/APIKit/Info.plist index 0e9f1f71..ebe40223 100644 --- a/Sources/APIKit/Info.plist +++ b/Sources/APIKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.0.0 + 5.0.0 CFBundleSignature ???? CFBundleVersion diff --git a/Sources/APIKit/Request.swift b/Sources/APIKit/Request.swift index e65e3819..efe68c97 100644 --- a/Sources/APIKit/Request.swift +++ b/Sources/APIKit/Request.swift @@ -1,5 +1,4 @@ import Foundation -import Result /// `Request` protocol represents a request for Web API. /// Following 5 items must be implemented. @@ -62,11 +61,11 @@ public protocol Request { } public extension Request { - public var parameters: Any? { + var parameters: Any? { return nil } - public var queryParameters: [String: Any]? { + var queryParameters: [String: Any]? { guard let parameters = parameters as? [String: Any], method.prefersQueryParameters else { return nil } @@ -74,7 +73,7 @@ public extension Request { return parameters } - public var bodyParameters: BodyParameters? { + var bodyParameters: BodyParameters? { guard let parameters = parameters, !method.prefersQueryParameters else { return nil } @@ -82,19 +81,19 @@ public extension Request { return JSONBodyParameters(JSONObject: parameters) } - public var headerFields: [String: String] { + var headerFields: [String: String] { return [:] } - public var dataParser: DataParser { + var dataParser: DataParser { return JSONDataParser(readingOptions: []) } - public func intercept(urlRequest: URLRequest) throws -> URLRequest { + func intercept(urlRequest: URLRequest) throws -> URLRequest { return urlRequest } - public func intercept(object: Any, urlResponse: HTTPURLResponse) throws -> Any { + func intercept(object: Any, urlResponse: HTTPURLResponse) throws -> Any { guard 200..<300 ~= urlResponse.statusCode else { throw ResponseError.unacceptableStatusCode(urlResponse.statusCode) } @@ -103,7 +102,7 @@ public extension Request { /// Builds `URLRequest` from properties of `self`. /// - Throws: `RequestError`, `Error` - public func buildURLRequest() throws -> URLRequest { + func buildURLRequest() throws -> URLRequest { let url = path.isEmpty ? baseURL : baseURL.appendingPathComponent(path) guard var components = URLComponents(url: url, resolvingAgainstBaseURL: true) else { throw RequestError.invalidBaseURL(baseURL) @@ -140,7 +139,7 @@ public extension Request { /// Builds `Response` from response `Data`. /// - Throws: `ResponseError`, `Error` - public func parse(data: Data, urlResponse: HTTPURLResponse) throws -> Response { + func parse(data: Data, urlResponse: HTTPURLResponse) throws -> Response { let parsedObject = try dataParser.parse(data: data) let passedObject = try intercept(object: parsedObject, urlResponse: urlResponse) return try response(from: passedObject, urlResponse: urlResponse) diff --git a/Sources/APIKit/Session.swift b/Sources/APIKit/Session.swift index 72a9405e..606531a6 100644 --- a/Sources/APIKit/Session.swift +++ b/Sources/APIKit/Session.swift @@ -1,5 +1,4 @@ import Foundation -import Result private var taskRequestKey = 0 diff --git a/Sources/APIKit/Unavailable.swift b/Sources/APIKit/Unavailable.swift index 92765230..2c05f7f6 100644 --- a/Sources/APIKit/Unavailable.swift +++ b/Sources/APIKit/Unavailable.swift @@ -6,8 +6,6 @@ // Copyright © 2016 Yosuke Ishikawa. All rights reserved. // -import Result - // MARK: - Protocols @available(*, unavailable, renamed: "Request") diff --git a/Tests/APIKitTests/SessionTests.swift b/Tests/APIKitTests/SessionTests.swift index 138fdf9f..d65a235e 100644 --- a/Tests/APIKitTests/SessionTests.swift +++ b/Tests/APIKitTests/SessionTests.swift @@ -1,7 +1,6 @@ import Foundation import APIKit import XCTest -import Result class SessionTests: XCTestCase { var adapter: TestSessionAdapter! diff --git a/Tests/APIKitTests/TestComponents/HTTPStub.swift b/Tests/APIKitTests/TestComponents/HTTPStub.swift index b56ff6d5..6170d79f 100644 --- a/Tests/APIKitTests/TestComponents/HTTPStub.swift +++ b/Tests/APIKitTests/TestComponents/HTTPStub.swift @@ -1,6 +1,5 @@ import Foundation import Dispatch -import Result class HTTPStub: URLProtocol { static var stubResult: Result = .success(Data())