From f2c87bc39a9c5229f7448303d6fbcdf6b9bee234 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Mon, 19 Nov 2018 16:40:29 +0800 Subject: [PATCH 1/7] swift 4.2 --- Cartfile | 2 +- Cartfile.private | 2 +- Cartfile.resolved | 4 ++-- Carthage/Checkouts/APIKit | 2 +- Carthage/Checkouts/Result | 2 +- JSONRPCKit.podspec | 2 +- JSONRPCKit.xcodeproj/project.pbxproj | 12 ++++++------ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ Package.resolved | 4 ++-- Package.swift | 2 +- Sources/JSONRPCKit/BatchElement.swift | 2 +- 11 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 JSONRPCKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Cartfile b/Cartfile index fa9f48b..1e95470 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "antitypical/Result" ~> 3.2.0 +github "antitypical/Result" ~> 4.0.0 diff --git a/Cartfile.private b/Cartfile.private index 8b3aa2a..0c7bd3e 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1 +1 @@ -github "ishkawa/APIKit" ~> 3.2.0 +github "ishkawa/APIKit" ~> 4.0.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 3d02dae..0c1205e 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "antitypical/Result" "3.2.4" -github "ishkawa/APIKit" "3.2.0" +github "antitypical/Result" "4.0.0" +github "ishkawa/APIKit" "4.0.0" diff --git a/Carthage/Checkouts/APIKit b/Carthage/Checkouts/APIKit index 0afa74d..dc4350d 160000 --- a/Carthage/Checkouts/APIKit +++ b/Carthage/Checkouts/APIKit @@ -1 +1 @@ -Subproject commit 0afa74dedff0df678af02fc2b474c4eafba37a67 +Subproject commit dc4350d686deb13e4c88418c5de1f2e1ecac0b82 diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result index 7477584..8fc088d 160000 --- a/Carthage/Checkouts/Result +++ b/Carthage/Checkouts/Result @@ -1 +1 @@ -Subproject commit 7477584259bfce2560a19e06ad9f71db441fff11 +Subproject commit 8fc088dcf72802801efeecba76ea8fb041fb773d diff --git a/JSONRPCKit.podspec b/JSONRPCKit.podspec index 91337fe..e50bece 100644 --- a/JSONRPCKit.podspec +++ b/JSONRPCKit.podspec @@ -28,6 +28,6 @@ Pod::Spec.new do |s| 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. LICENSE } - s.dependency "Result", "~> 3.2.0" + s.dependency "Result", "~> 4.0.0" end diff --git a/JSONRPCKit.xcodeproj/project.pbxproj b/JSONRPCKit.xcodeproj/project.pbxproj index f31ac6e..d83bd59 100644 --- a/JSONRPCKit.xcodeproj/project.pbxproj +++ b/JSONRPCKit.xcodeproj/project.pbxproj @@ -206,11 +206,11 @@ TargetAttributes = { 7FC654FF1D49EA19004C390C = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0920; + LastSwiftMigration = 1010; }; CBB0C34D1BF0B1D6006A7D41 = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0920; + LastSwiftMigration = 1010; }; }; }; @@ -298,7 +298,7 @@ "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "-.Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -312,7 +312,7 @@ "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "-.Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -445,7 +445,7 @@ PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -467,7 +467,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.bricklife.JSONRPCKit; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/JSONRPCKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/JSONRPCKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/JSONRPCKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Package.resolved b/Package.resolved index 3236c9e..dc09c89 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/antitypical/Result.git", "state": { "branch": null, - "revision": "7477584259bfce2560a19e06ad9f71db441fff11", - "version": "3.2.4" + "revision": "8fc088dcf72802801efeecba76ea8fb041fb773d", + "version": "4.0.0" } } ] diff --git a/Package.swift b/Package.swift index a1bec29..aed5491 100644 --- a/Package.swift +++ b/Package.swift @@ -9,7 +9,7 @@ let package = Package( .library(name: "JSONRPCKit", targets: ["JSONRPCKit"]), ], dependencies: [ - .package(url: "https://github.com/antitypical/Result.git", from: "3.2.0"), + .package(url: "https://github.com/antitypical/Result.git", from: "4.0.0"), ], targets: [ .target(name: "JSONRPCKit", dependencies: ["Result"]), diff --git a/Sources/JSONRPCKit/BatchElement.swift b/Sources/JSONRPCKit/BatchElement.swift index c8e3649..a74edd0 100644 --- a/Sources/JSONRPCKit/BatchElement.swift +++ b/Sources/JSONRPCKit/BatchElement.swift @@ -82,7 +82,7 @@ internal extension BatchElementProcotol { internal func result(from objects: [Any]) -> Result { let matchedObject = objects - .flatMap { $0 as? [String: Any] } + .compactMap { $0 as? [String: Any] } .filter { $0["id"].flatMap(Id.init) == id } .first From 86de6c9dbfc6869958fb2872e216cdc6449bbf7e Mon Sep 17 00:00:00 2001 From: zhangliang Date: Wed, 9 Oct 2019 18:09:43 +0800 Subject: [PATCH 2/7] swift 5.0 --- Cartfile | 2 +- Cartfile.private | 2 +- Cartfile.resolved | 4 +- Carthage/Checkouts/APIKit | 2 +- Carthage/Checkouts/Result | 2 +- Example/Example.xcodeproj/project.pbxproj | 40 +++++++--- .../xcshareddata/xcschemes/Example.xcscheme | 78 +++++++++++++++++++ .../AppIcon.appiconset/Contents.json | 25 ++++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ Sources/JSONRPCKit/Batch.swift | 42 +++++----- Sources/JSONRPCKit/BatchElement.swift | 18 ++--- Sources/JSONRPCKit/Id.swift | 6 +- Sources/JSONRPCKit/Request.swift | 10 +-- 13 files changed, 183 insertions(+), 56 deletions(-) create mode 100644 Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme create mode 100644 JSONRPCKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Cartfile b/Cartfile index fa9f48b..fc26a15 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "antitypical/Result" ~> 3.2.0 +github "antitypical/Result" ~> 5.0.0 diff --git a/Cartfile.private b/Cartfile.private index 8b3aa2a..762c767 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1 +1 @@ -github "ishkawa/APIKit" ~> 3.2.0 +github "ishkawa/APIKit" ~> 5.0.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 3d02dae..44a0e4f 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "antitypical/Result" "3.2.4" -github "ishkawa/APIKit" "3.2.0" +github "antitypical/Result" "5.0.0" +github "ishkawa/APIKit" "5.0.0" diff --git a/Carthage/Checkouts/APIKit b/Carthage/Checkouts/APIKit index 0afa74d..862a8f8 160000 --- a/Carthage/Checkouts/APIKit +++ b/Carthage/Checkouts/APIKit @@ -1 +1 @@ -Subproject commit 0afa74dedff0df678af02fc2b474c4eafba37a67 +Subproject commit 862a8f80dd117693750c6ddaba2fe6a85b061a9a diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result index 7477584..12920a5 160000 --- a/Carthage/Checkouts/Result +++ b/Carthage/Checkouts/Result @@ -1 +1 @@ -Subproject commit 7477584259bfce2560a19e06ad9f71db441fff11 +Subproject commit 12920a5c2595926efab9274d6003e29f503dbb66 diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index a2cac19..7e41c51 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -7,12 +7,13 @@ objects = { /* Begin PBXBuildFile section */ - 7FD0A33F1D4B5926007C9EAB /* APIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FD0A33E1D4B5926007C9EAB /* APIKit.framework */; }; 7FD0A3431D4B5E80007C9EAB /* UIViewController+Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FD0A3421D4B5E80007C9EAB /* UIViewController+Error.swift */; }; - CB31EFB11CF6E88100DD13DD /* JSONRPCKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB31EFB01CF6E88100DD13DD /* JSONRPCKit.framework */; }; - CB31EFB21CF6E88100DD13DD /* JSONRPCKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CB31EFB01CF6E88100DD13DD /* JSONRPCKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CB31EFB41CF6E88800DD13DD /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB31EFB31CF6E88800DD13DD /* Result.framework */; }; - CB31EFB51CF6E88800DD13DD /* Result.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CB31EFB31CF6E88800DD13DD /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + AF5885C4234DE8EF0068D373 /* APIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF5885C3234DE8EF0068D373 /* APIKit.framework */; }; + AF5885C5234DE8EF0068D373 /* APIKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AF5885C3234DE8EF0068D373 /* APIKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + AF5885C6234DE8EF0068D373 /* JSONRPCKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF5885BD234DE5AC0068D373 /* JSONRPCKit.framework */; }; + AF5885C7234DE8EF0068D373 /* JSONRPCKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AF5885BD234DE5AC0068D373 /* JSONRPCKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + AF5885C8234DE8EF0068D373 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF5885BE234DE5AC0068D373 /* Result.framework */; }; + AF5885C9234DE8EF0068D373 /* Result.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AF5885BE234DE5AC0068D373 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CB63E2471CE2309100E22B5C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB63E2461CE2309100E22B5C /* AppDelegate.swift */; }; CB63E24C1CE2309100E22B5C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CB63E24A1CE2309100E22B5C /* Main.storyboard */; }; CB63E24E1CE2309100E22B5C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CB63E24D1CE2309100E22B5C /* Assets.xcassets */; }; @@ -23,14 +24,15 @@ /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ - CB31EFAF1CF6E84400DD13DD /* Embed Frameworks */ = { + AF5885CA234DE8EF0068D373 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 10; files = ( - CB31EFB21CF6E88100DD13DD /* JSONRPCKit.framework in Embed Frameworks */, - CB31EFB51CF6E88800DD13DD /* Result.framework in Embed Frameworks */, + AF5885C9234DE8EF0068D373 /* Result.framework in Embed Frameworks */, + AF5885C5234DE8EF0068D373 /* APIKit.framework in Embed Frameworks */, + AF5885C7234DE8EF0068D373 /* JSONRPCKit.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -40,6 +42,9 @@ /* Begin PBXFileReference section */ 7FD0A33E1D4B5926007C9EAB /* APIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = APIKit.framework; path = ../Carthage/Checkouts/APIKit/build/Debug/APIKit.framework; sourceTree = ""; }; 7FD0A3421D4B5E80007C9EAB /* UIViewController+Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Error.swift"; sourceTree = ""; }; + AF5885BD234DE5AC0068D373 /* JSONRPCKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = JSONRPCKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + AF5885BE234DE5AC0068D373 /* Result.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Result.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + AF5885C3234DE8EF0068D373 /* APIKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = APIKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CB31EFB01CF6E88100DD13DD /* JSONRPCKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = JSONRPCKit.framework; path = "../Debug-iphonesimulator/JSONRPCKit.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; CB31EFB31CF6E88800DD13DD /* Result.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Result.framework; path = "../Debug-iphonesimulator/Result.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; CB31EFB61CF6E8B400DD13DD /* Alamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Alamofire.framework; path = "../Debug-iphonesimulator/Alamofire.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -59,9 +64,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 7FD0A33F1D4B5926007C9EAB /* APIKit.framework in Frameworks */, - CB31EFB11CF6E88100DD13DD /* JSONRPCKit.framework in Frameworks */, - CB31EFB41CF6E88800DD13DD /* Result.framework in Frameworks */, + AF5885C8234DE8EF0068D373 /* Result.framework in Frameworks */, + AF5885C4234DE8EF0068D373 /* APIKit.framework in Frameworks */, + AF5885C6234DE8EF0068D373 /* JSONRPCKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -104,6 +109,9 @@ CB63E26E1CE232C700E22B5C /* Frameworks */ = { isa = PBXGroup; children = ( + AF5885C3234DE8EF0068D373 /* APIKit.framework */, + AF5885BD234DE5AC0068D373 /* JSONRPCKit.framework */, + AF5885BE234DE5AC0068D373 /* Result.framework */, 7FD0A33E1D4B5926007C9EAB /* APIKit.framework */, CB31EFB61CF6E8B400DD13DD /* Alamofire.framework */, CB31EFB01CF6E88100DD13DD /* JSONRPCKit.framework */, @@ -122,7 +130,7 @@ CB63E23F1CE2309100E22B5C /* Sources */, CB63E2401CE2309100E22B5C /* Frameworks */, CB63E2411CE2309100E22B5C /* Resources */, - CB31EFAF1CF6E84400DD13DD /* Embed Frameworks */, + AF5885CA234DE8EF0068D373 /* Embed Frameworks */, ); buildRules = ( ); @@ -146,6 +154,7 @@ CB63E2421CE2309100E22B5C = { CreatedOnToolsVersion = 7.3.1; LastSwiftMigration = 0920; + ProvisioningStyle = Manual; }; }; }; @@ -154,6 +163,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -321,10 +331,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Example/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.bricklife.ios.Example; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.0; }; name = Debug; @@ -333,10 +346,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Example/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.bricklife.ios.Example; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.0; }; name = Release; diff --git a/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme new file mode 100644 index 0000000..50fe757 --- /dev/null +++ b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json index eeea76c..d8db8d6 100644 --- a/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -30,6 +40,16 @@ "size" : "60x60", "scale" : "3x" }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, { "idiom" : "ipad", "size" : "29x29", @@ -64,6 +84,11 @@ "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/JSONRPCKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/JSONRPCKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/JSONRPCKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Sources/JSONRPCKit/Batch.swift b/Sources/JSONRPCKit/Batch.swift index bec1a47..1b6c93d 100644 --- a/Sources/JSONRPCKit/Batch.swift +++ b/Sources/JSONRPCKit/Batch.swift @@ -40,7 +40,7 @@ public struct Batch1: Batch { } public static func responses(from results: Results) throws -> Responses { - return try results.dematerialize() + return try results.get() } } @@ -85,8 +85,8 @@ public struct Batch2: Batch { public static func responses(from results: Results) throws -> Responses { return ( - try results.0.dematerialize(), - try results.1.dematerialize() + try results.0.get(), + try results.1.get() ) } } @@ -137,9 +137,9 @@ public struct Batch3: B public static func responses(from results: Results) throws -> Responses { return ( - try results.0.dematerialize(), - try results.1.dematerialize(), - try results.2.dematerialize() + try results.0.get(), + try results.1.get(), + try results.2.get() ) } } @@ -195,10 +195,10 @@ public struct Batch4 Responses { return ( - try results.0.dematerialize(), - try results.1.dematerialize(), - try results.2.dematerialize(), - try results.3.dematerialize() + try results.0.get(), + try results.1.get(), + try results.2.get(), + try results.3.get() ) } } @@ -259,11 +259,11 @@ public struct Batch5 Responses { return ( - try results.0.dematerialize(), - try results.1.dematerialize(), - try results.2.dematerialize(), - try results.3.dematerialize(), - try results.4.dematerialize() + try results.0.get(), + try results.1.get(), + try results.2.get(), + try results.3.get(), + try results.4.get() ) } } @@ -329,12 +329,12 @@ public struct Batch6 Responses { return ( - try results.0.dematerialize(), - try results.1.dematerialize(), - try results.2.dematerialize(), - try results.3.dematerialize(), - try results.4.dematerialize(), - try results.5.dematerialize() + try results.0.get(), + try results.1.get(), + try results.2.get(), + try results.3.get(), + try results.4.get(), + try results.5.get() ) } } diff --git a/Sources/JSONRPCKit/BatchElement.swift b/Sources/JSONRPCKit/BatchElement.swift index c8e3649..cd20411 100644 --- a/Sources/JSONRPCKit/BatchElement.swift +++ b/Sources/JSONRPCKit/BatchElement.swift @@ -26,7 +26,7 @@ internal protocol BatchElementProcotol { internal extension BatchElementProcotol { /// - Throws: JSONRPCError - internal func response(from object: Any) throws -> Request.Response { + func response(from object: Any) throws -> Request.Response { switch result(from: object) { case .success(let response): return response @@ -37,7 +37,7 @@ internal extension BatchElementProcotol { } /// - Throws: JSONRPCError - internal func response(from objects: [Any]) throws -> Request.Response { + func response(from objects: [Any]) throws -> Request.Response { switch result(from: objects) { case .success(let response): return response @@ -47,7 +47,7 @@ internal extension BatchElementProcotol { } } - internal func result(from object: Any) -> Result { + func result(from object: Any) -> Result { guard let dictionary = object as? [String: Any] else { return .failure(.unexpectedTypeObject(object)) } @@ -80,9 +80,9 @@ internal extension BatchElementProcotol { } } - internal func result(from objects: [Any]) -> Result { + func result(from objects: [Any]) -> Result { let matchedObject = objects - .flatMap { $0 as? [String: Any] } + .compactMap { $0 as? [String: Any] } .filter { $0["id"].flatMap(Id.init) == id } .first @@ -95,19 +95,19 @@ internal extension BatchElementProcotol { } internal extension BatchElementProcotol where Request.Response == Void { - internal func response(_ object: Any) throws -> Request.Response { + func response(_ object: Any) throws -> Request.Response { return () } - internal func response(_ objects: [Any]) throws -> Request.Response { + func response(_ objects: [Any]) throws -> Request.Response { return () } - internal func result(_ object: Any) -> Result { + func result(_ object: Any) -> Result { return .success(()) } - internal func result(_ objects: [Any]) -> Result { + func result(_ objects: [Any]) -> Result { return .success(()) } } diff --git a/Sources/JSONRPCKit/Id.swift b/Sources/JSONRPCKit/Id.swift index b742cbd..f9bb716 100644 --- a/Sources/JSONRPCKit/Id.swift +++ b/Sources/JSONRPCKit/Id.swift @@ -38,12 +38,12 @@ extension Id { extension Id: Hashable { - public var hashValue: Int { + public func hash(into hasher: inout Hasher) { switch self { case .number(let number): - return number + hasher.combine(number) case .string(let string): - return string.hashValue + hasher.combine(string) } } } diff --git a/Sources/JSONRPCKit/Request.swift b/Sources/JSONRPCKit/Request.swift index 6394295..f4c1a00 100644 --- a/Sources/JSONRPCKit/Request.swift +++ b/Sources/JSONRPCKit/Request.swift @@ -21,25 +21,25 @@ public protocol Request { } public extension Request { - public var parameters: Any? { + var parameters: Any? { return nil } - public var extendedFields: [String: Any]? { + var extendedFields: [String: Any]? { return nil } - public var isNotification: Bool { + var isNotification: Bool { return false } } public extension Request where Response == Void { - public var isNotification: Bool { + var isNotification: Bool { return true } - public func response(from resultObject: Any) throws -> Response { + func response(from resultObject: Any) throws -> Response { return () } } From eb126d72926be5bcc925e6e6449138ba36b16daa Mon Sep 17 00:00:00 2001 From: zhangliang Date: Wed, 9 Oct 2019 18:32:12 +0800 Subject: [PATCH 3/7] yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4800cc..dbe4c85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ branches: matrix: include: - os: osx - osx_image: xcode9 + osx_image: xcode11 language: objective-c env: - JOB=Xcode @@ -21,7 +21,7 @@ matrix: - xcodebuild build -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk watchsimulator | xcpretty -c - pod lib lint - os: osx - osx_image: xcode9 + osx_image: xcode11 language: generic env: - JOB=SPM @@ -33,7 +33,7 @@ matrix: language: generic env: - JOB=Linux - - SWIFT_VERSION=4.0.3 + - SWIFT_VERSION=5.1 script: - swift --version - swift build From 9558039eb98fb613d3511367595a04703e90591e Mon Sep 17 00:00:00 2001 From: zhangliang Date: Wed, 9 Oct 2019 18:47:31 +0800 Subject: [PATCH 4/7] yml carthage --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index dbe4c85..20e4804 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,8 @@ matrix: - JOB=Xcode script: - set -o pipefail + - brew install carthage + - carthage update --no-use-binaries --platform ios - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit | xcpretty -c - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk iphonesimulator -destination "name=iPhone SE" | xcpretty -c - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk appletvsimulator -destination "name=Apple TV 1080p" | xcpretty -c From 2a9d565cfa3b9774a5a0b4d02f967a0d8ff259a8 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Wed, 9 Oct 2019 19:03:42 +0800 Subject: [PATCH 5/7] yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 20e4804..6e82d8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,11 +15,10 @@ matrix: - JOB=Xcode script: - set -o pipefail - - brew install carthage - carthage update --no-use-binaries --platform ios - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit | xcpretty -c - - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk iphonesimulator -destination "name=iPhone SE" | xcpretty -c - - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk appletvsimulator -destination "name=Apple TV 1080p" | xcpretty -c + - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk iphonesimulator -destination "platform:iOS Simulator, id:6BDC8C76-0150-4996-9EF0-0AD5E06B45B8, OS:12.2, name:iPhone X" | xcpretty -c + - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk appletvsimulator -destination "platform:tvOS Simulator, id:DF9803E1-42F1-40EC-9BB5-076173CD4E1E, OS:10.2, name:Apple TV 1080p" | xcpretty -c - xcodebuild build -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk watchsimulator | xcpretty -c - pod lib lint - os: osx @@ -28,6 +27,7 @@ matrix: env: - JOB=SPM script: + - carthage update --no-use-binaries --platform ios - swift --version - swift build - swift test From 1a9da4b05ea8ba58362223f0fb926d74361c8a69 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Thu, 10 Oct 2019 10:58:56 +0800 Subject: [PATCH 6/7] yml --- .travis.yml | 11 +++++------ Example/Example.xcodeproj/project.pbxproj | 13 ++++++++----- JSONRPCKit.xcodeproj/project.pbxproj | 5 +++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e82d8c..9d4d90f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,25 +9,24 @@ branches: matrix: include: - os: osx - osx_image: xcode11 + osx_image: xcode11.1 language: objective-c env: - JOB=Xcode script: - set -o pipefail - - carthage update --no-use-binaries --platform ios - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit | xcpretty -c - - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk iphonesimulator -destination "platform:iOS Simulator, id:6BDC8C76-0150-4996-9EF0-0AD5E06B45B8, OS:12.2, name:iPhone X" | xcpretty -c - - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk appletvsimulator -destination "platform:tvOS Simulator, id:DF9803E1-42F1-40EC-9BB5-076173CD4E1E, OS:10.2, name:Apple TV 1080p" | xcpretty -c + - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk iphonesimulator -destination "name=iPhone SE" | xcpretty -c + - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk appletvsimulator -destination "name=Apple TV" | xcpretty -c - xcodebuild build -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk watchsimulator | xcpretty -c + - gem install cocoapods --pre - pod lib lint - os: osx - osx_image: xcode11 + osx_image: xcode11.1 language: generic env: - JOB=SPM script: - - carthage update --no-use-binaries --platform ios - swift --version - swift build - swift test diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 7e41c51..1375a49 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -153,8 +153,9 @@ TargetAttributes = { CB63E2421CE2309100E22B5C = { CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = 6AS4N82Q9E; LastSwiftMigration = 0920; - ProvisioningStyle = Manual; + ProvisioningStyle = Automatic; }; }; }; @@ -331,8 +332,9 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Manual; - DEVELOPMENT_TEAM = ""; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6AS4N82Q9E; INFOPLIST_FILE = Example/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.bricklife.ios.Example; @@ -346,8 +348,9 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Manual; - DEVELOPMENT_TEAM = ""; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6AS4N82Q9E; INFOPLIST_FILE = Example/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.bricklife.ios.Example; diff --git a/JSONRPCKit.xcodeproj/project.pbxproj b/JSONRPCKit.xcodeproj/project.pbxproj index d83bd59..cffccf0 100644 --- a/JSONRPCKit.xcodeproj/project.pbxproj +++ b/JSONRPCKit.xcodeproj/project.pbxproj @@ -219,6 +219,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -445,7 +446,7 @@ PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -467,7 +468,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.bricklife.JSONRPCKit; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; From df6ceda2697852d41b6dc530d4fadc8f05803884 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Thu, 10 Oct 2019 11:09:02 +0800 Subject: [PATCH 7/7] yml --- .swift-version | 1 - .swift-versions | 1 + .travis.yml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 .swift-version create mode 100644 .swift-versions diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 5186d07..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4.0 diff --git a/.swift-versions b/.swift-versions new file mode 100644 index 0000000..a75b92f --- /dev/null +++ b/.swift-versions @@ -0,0 +1 @@ +5.1 diff --git a/.travis.yml b/.travis.yml index 9d4d90f..5fab9c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: script: - set -o pipefail - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit | xcpretty -c - - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk iphonesimulator -destination "name=iPhone SE" | xcpretty -c + - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk iphonesimulator -destination "name=iPhone 11" | xcpretty -c - xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk appletvsimulator -destination "name=Apple TV" | xcpretty -c - xcodebuild build -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk watchsimulator | xcpretty -c - gem install cocoapods --pre