From ea240360fc798faf4536860717e78b91389ca02a Mon Sep 17 00:00:00 2001 From: Samuel Goodwin Date: Fri, 7 Jun 2019 17:08:15 +0200 Subject: [PATCH] Support Swift 5.0 (#123) * Update Swish for Swift 5.0. Using the latest Quick and Nimble was pretty much the only code change required. We no longer need a framework for Result (even though this is was a good one). It's included in the standard library now, so the only thing we needed was an extension to add value and error to keep the tests happy (and anyone who was depending on those in their code). * Adjust from feedback. Needed to ignore a new file and I was incorrectly creating a new decoder in my fix (not sure how this worked in my tests like this). * Removing the need for Result. Now that Swift 5 provides this, we don't need it. * Eliminate Result extension. This caused the compiler to crash initially because there's so much type inferrence going on in the tests that it couldn't even report errors. I think I got it worked out to keep the intent behind the test without having the `value` and `error` fields. --- .gitignore | 1 - .gitmodules | 3 - Cartfile | 1 - Cartfile.private | 4 +- Cartfile.resolved | 5 +- Carthage/Checkouts/Nimble | 2 +- Carthage/Checkouts/Quick | 2 +- Carthage/Checkouts/Result | 1 - Source/Models/APIClient.swift | 1 - Source/Models/NetworkRequestPerformer.swift | 1 - Source/Protocols/Client.swift | 1 - Source/Protocols/Request.swift | 1 - Source/Protocols/RequestPerformer.swift | 1 - Swish.xcodeproj/project.pbxproj | 72 ++++++------------- .../xcshareddata/xcschemes/Swish-Mac.xcscheme | 2 +- .../xcshareddata/xcschemes/Swish-iOS.xcscheme | 3 +- .../xcschemes/Swish-tvOS.xcscheme | 2 +- .../xcschemes/Swish-watchOS.xcscheme | 2 +- Swish.xcworkspace/contents.xcworkspacedata | 3 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++ SwishExamples.playground/Contents.swift | 1 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++ Tests/Fakes/FakeRequest.swift | 1 - Tests/Fakes/FakeRequestPerformer.swift | 1 - Tests/Helpers/NimbleMatchers.swift | 1 - Tests/Tests/APIClientSpec.swift | 55 +++++++------- Tests/Tests/NetworkRequestPerformerSpec.swift | 12 ++-- Tests/Tests/RequestSpec.swift | 1 - 28 files changed, 84 insertions(+), 112 deletions(-) delete mode 160000 Carthage/Checkouts/Result create mode 100644 Swish.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 SwishExamples.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.gitignore b/.gitignore index 922780e..c30679d 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,3 @@ Carthage/Build .idea/ *.iml -Argo.framework.zip diff --git a/.gitmodules b/.gitmodules index 913d093..3c64704 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "Carthage/Checkouts/Result"] - path = Carthage/Checkouts/Result - url = https://github.com/antitypical/Result.git [submodule "Carthage/Checkouts/Nimble"] path = Carthage/Checkouts/Nimble url = https://github.com/Quick/Nimble.git diff --git a/Cartfile b/Cartfile index e9bc3ad..e69de29 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +0,0 @@ -github "antitypical/Result" ~> 4.0 diff --git a/Cartfile.private b/Cartfile.private index 822df85..5791b6e 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ -github "Quick/Quick" ~> 1.3 -github "Quick/Nimble" ~> 7.0 +github "Quick/Quick" ~> 2.0 +github "Quick/Nimble" ~> 8.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index def453d..810925c 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,2 @@ -github "Quick/Nimble" "v7.3.1" -github "Quick/Quick" "v1.3.2" -github "antitypical/Result" "4.0.0" +github "Quick/Nimble" "v8.0.1" +github "Quick/Quick" "v2.1.0" diff --git a/Carthage/Checkouts/Nimble b/Carthage/Checkouts/Nimble index cd6dfb8..43304bf 160000 --- a/Carthage/Checkouts/Nimble +++ b/Carthage/Checkouts/Nimble @@ -1 +1 @@ -Subproject commit cd6dfb86f496fcd96ce0bc6da962cd936bf41903 +Subproject commit 43304bf2b1579fd555f2fdd51742771c1e4f2b98 diff --git a/Carthage/Checkouts/Quick b/Carthage/Checkouts/Quick index 5fbf138..94df9b4 160000 --- a/Carthage/Checkouts/Quick +++ b/Carthage/Checkouts/Quick @@ -1 +1 @@ -Subproject commit 5fbf13871d185526993130c3a1fad0b70bfe37ce +Subproject commit 94df9b449508344667e5afc7e80f8bcbff1e4c37 diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result deleted file mode 160000 index 8fc088d..0000000 --- a/Carthage/Checkouts/Result +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8fc088dcf72802801efeecba76ea8fb041fb773d diff --git a/Source/Models/APIClient.swift b/Source/Models/APIClient.swift index 7161f51..302456a 100644 --- a/Source/Models/APIClient.swift +++ b/Source/Models/APIClient.swift @@ -1,5 +1,4 @@ import Foundation -import Result public struct APIClient { fileprivate let requestPerformer: RequestPerformer diff --git a/Source/Models/NetworkRequestPerformer.swift b/Source/Models/NetworkRequestPerformer.swift index fa19d6e..373648d 100644 --- a/Source/Models/NetworkRequestPerformer.swift +++ b/Source/Models/NetworkRequestPerformer.swift @@ -1,5 +1,4 @@ import Foundation -import Result public struct NetworkRequestPerformer: RequestPerformer { fileprivate let session: URLSession diff --git a/Source/Protocols/Client.swift b/Source/Protocols/Client.swift index 961e23d..483489f 100644 --- a/Source/Protocols/Client.swift +++ b/Source/Protocols/Client.swift @@ -1,5 +1,4 @@ import Foundation -import Result public protocol Client { @discardableResult diff --git a/Source/Protocols/Request.swift b/Source/Protocols/Request.swift index eedaf9b..f2cf924 100644 --- a/Source/Protocols/Request.swift +++ b/Source/Protocols/Request.swift @@ -1,5 +1,4 @@ import Foundation -import Result public typealias EmptyResponse = Void diff --git a/Source/Protocols/RequestPerformer.swift b/Source/Protocols/RequestPerformer.swift index aed9de3..642dce4 100644 --- a/Source/Protocols/RequestPerformer.swift +++ b/Source/Protocols/RequestPerformer.swift @@ -1,5 +1,4 @@ import Foundation -import Result public protocol RequestPerformer { @discardableResult diff --git a/Swish.xcodeproj/project.pbxproj b/Swish.xcodeproj/project.pbxproj index e680e27..058942f 100644 --- a/Swish.xcodeproj/project.pbxproj +++ b/Swish.xcodeproj/project.pbxproj @@ -7,25 +7,18 @@ objects = { /* Begin PBXBuildFile section */ - 1F1BF4F521C3F4FC004162F1 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF4F421C3F4FC004162F1 /* Result.framework */; }; 1F1BF4F821C3F516004162F1 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF4F621C3F516004162F1 /* Quick.framework */; }; 1F1BF4F921C3F516004162F1 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF4F721C3F516004162F1 /* Nimble.framework */; }; 1F1BF4FB21C416F4004162F1 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF4F721C3F516004162F1 /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 1F1BF4FC21C416F4004162F1 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF4F621C3F516004162F1 /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 1F1BF4FD21C416F4004162F1 /* Result.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF4F421C3F4FC004162F1 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 1F1BF50621CD33F6004162F1 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF50521CD33F6004162F1 /* Result.framework */; }; 1F1BF50921CD342D004162F1 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF50721CD342D004162F1 /* Nimble.framework */; }; 1F1BF50A21CD342D004162F1 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF50821CD342D004162F1 /* Quick.framework */; }; - 1F1BF51321CD35A2004162F1 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF51221CD35A2004162F1 /* Result.framework */; }; 1F1BF51621CD35E1004162F1 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF51421CD35E1004162F1 /* Nimble.framework */; }; 1F1BF51721CD35E1004162F1 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF51521CD35E1004162F1 /* Quick.framework */; }; 1F1BF52621CD371F004162F1 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF50721CD342D004162F1 /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 1F1BF52721CD3725004162F1 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF50821CD342D004162F1 /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 1F1BF52821CD3733004162F1 /* Result.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF50521CD33F6004162F1 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 1F1BF52921CD3760004162F1 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF51421CD35E1004162F1 /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 1F1BF52A21CD3763004162F1 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF51521CD35E1004162F1 /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 1F1BF52B21CD3768004162F1 /* Result.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F1BF51221CD35A2004162F1 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 1F1BF52D21CD3790004162F1 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1BF52C21CD3790004162F1 /* Result.framework */; }; 2C61A39E1BD726E10087B295 /* RequestMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = F867938B1BD29E37007D9E98 /* RequestMethod.swift */; }; 2C6DC97A1BD5AA3B006B4C96 /* NimbleMatchers.swift in Sources */ = {isa = PBXBuildFile; fileRef = E506EC7D1BB5BE380032E941 /* NimbleMatchers.swift */; }; 2C6DC97B1BD5AA3B006B4C96 /* FakeSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8DF3B811B964B20003177CD /* FakeSession.swift */; }; @@ -139,7 +132,6 @@ files = ( 1F1BF4FB21C416F4004162F1 /* Nimble.framework in CopyFiles */, 1F1BF4FC21C416F4004162F1 /* Quick.framework in CopyFiles */, - 1F1BF4FD21C416F4004162F1 /* Result.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -151,7 +143,6 @@ files = ( 1F1BF52621CD371F004162F1 /* Nimble.framework in CopyFiles */, 1F1BF52721CD3725004162F1 /* Quick.framework in CopyFiles */, - 1F1BF52821CD3733004162F1 /* Result.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -163,23 +154,18 @@ files = ( 1F1BF52921CD3760004162F1 /* Nimble.framework in CopyFiles */, 1F1BF52A21CD3763004162F1 /* Quick.framework in CopyFiles */, - 1F1BF52B21CD3768004162F1 /* Result.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 1F1BF4F421C3F4FC004162F1 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/iOS/Result.framework; sourceTree = ""; }; 1F1BF4F621C3F516004162F1 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = ""; }; 1F1BF4F721C3F516004162F1 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = ""; }; - 1F1BF50521CD33F6004162F1 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/Mac/Result.framework; sourceTree = ""; }; 1F1BF50721CD342D004162F1 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/Mac/Nimble.framework; sourceTree = ""; }; 1F1BF50821CD342D004162F1 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/Mac/Quick.framework; sourceTree = ""; }; - 1F1BF51221CD35A2004162F1 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/tvOS/Result.framework; sourceTree = ""; }; 1F1BF51421CD35E1004162F1 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/tvOS/Nimble.framework; sourceTree = ""; }; 1F1BF51521CD35E1004162F1 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/tvOS/Quick.framework; sourceTree = ""; }; - 1F1BF52C21CD3790004162F1 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/watchOS/Result.framework; sourceTree = ""; }; 2C721E401BD5A77700846414 /* Swish.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Swish.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2C721E491BD5A77700846414 /* Swish-MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Swish-MacTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 4A05CC271CEFBA460076955E /* Scheduler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Scheduler.swift; sourceTree = ""; }; @@ -219,7 +205,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1F1BF50621CD33F6004162F1 /* Result.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -237,7 +222,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1F1BF51321CD35A2004162F1 /* Result.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -255,7 +239,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1F1BF52D21CD3790004162F1 /* Result.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -263,7 +246,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1F1BF4F521C3F4FC004162F1 /* Result.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -379,16 +361,12 @@ F8DF3B7E1B964AF4003177CD /* Frameworks */ = { isa = PBXGroup; children = ( - 1F1BF52C21CD3790004162F1 /* Result.framework */, 1F1BF51421CD35E1004162F1 /* Nimble.framework */, 1F1BF51521CD35E1004162F1 /* Quick.framework */, - 1F1BF51221CD35A2004162F1 /* Result.framework */, 1F1BF50721CD342D004162F1 /* Nimble.framework */, 1F1BF50821CD342D004162F1 /* Quick.framework */, - 1F1BF50521CD33F6004162F1 /* Result.framework */, 1F1BF4F721C3F516004162F1 /* Nimble.framework */, 1F1BF4F621C3F516004162F1 /* Quick.framework */, - 1F1BF4F421C3F4FC004162F1 /* Result.framework */, ); name = Frameworks; sourceTree = ""; @@ -613,11 +591,11 @@ TargetAttributes = { 2C721E3F1BD5A77700846414 = { CreatedOnToolsVersion = 7.0.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; }; 2C721E481BD5A77700846414 = { CreatedOnToolsVersion = 7.0.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; }; E52E5D8E1CE7AE3400023C91 = { CreatedOnToolsVersion = 7.3; @@ -646,7 +624,9 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, + Base, ); mainGroup = F80694E71B962BB900C61B4A; productRefGroup = F80694F21B962BB900C61B4A /* Products */; @@ -880,7 +860,7 @@ PRODUCT_NAME = Swish; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -906,7 +886,7 @@ PRODUCT_NAME = Swish; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -924,7 +904,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.thoughtbot.SwishTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -942,7 +922,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.thoughtbot.SwishTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -957,8 +937,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Checkouts/Argo/build/Debug-appletvos", - "$(PROJECT_DIR)/Carthage/Checkouts/Result/build/Debug-appletvos", "$(PROJECT_DIR)/Carthage/Build/tvOS", ); INFOPLIST_FILE = Source/Resources/Info.plist; @@ -968,7 +946,7 @@ PRODUCT_NAME = Swish; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; }; name = Debug; @@ -984,8 +962,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Checkouts/Argo/build/Debug-appletvos", - "$(PROJECT_DIR)/Carthage/Checkouts/Result/build/Debug-appletvos", "$(PROJECT_DIR)/Carthage/Build/tvOS", ); INFOPLIST_FILE = Source/Resources/Info.plist; @@ -995,7 +971,7 @@ PRODUCT_NAME = Swish; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; }; name = Release; @@ -1006,8 +982,6 @@ CLANG_ANALYZER_NONNULL = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Checkouts/Quick/build/Debug-appletvos", - "$(PROJECT_DIR)/Carthage/Checkouts/Nimble/build/Debug-appletvos", "$(PROJECT_DIR)/Carthage/Build/tvOS", ); INFOPLIST_FILE = Tests/Resources/Info.plist; @@ -1015,7 +989,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.thoughtbot.Swish-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; }; name = Debug; }; @@ -1025,8 +1000,6 @@ CLANG_ANALYZER_NONNULL = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Checkouts/Quick/build/Debug-appletvos", - "$(PROJECT_DIR)/Carthage/Checkouts/Nimble/build/Debug-appletvos", "$(PROJECT_DIR)/Carthage/Build/tvOS", ); INFOPLIST_FILE = Tests/Resources/Info.plist; @@ -1034,7 +1007,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.thoughtbot.Swish-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; }; name = Release; }; @@ -1050,8 +1024,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Checkouts/Argo/build/Debug-watchos", - "$(PROJECT_DIR)/Carthage/Checkouts/Result/build/Debug-watchos", "$(PROJECT_DIR)/Carthage/Build/watchOS", ); INFOPLIST_FILE = Source/Resources/Info.plist; @@ -1061,7 +1033,7 @@ PRODUCT_NAME = Swish; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; }; name = Debug; @@ -1078,8 +1050,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Carthage/Checkouts/Argo/build/Debug-watchos", - "$(PROJECT_DIR)/Carthage/Checkouts/Result/build/Debug-watchos", "$(PROJECT_DIR)/Carthage/Build/watchOS", ); INFOPLIST_FILE = Source/Resources/Info.plist; @@ -1089,7 +1059,7 @@ PRODUCT_NAME = Swish; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; }; name = Release; @@ -1146,6 +1116,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -1199,6 +1170,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; @@ -1229,7 +1201,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.thoughtbot.Swish; PRODUCT_NAME = Swish; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1254,7 +1226,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.thoughtbot.Swish; PRODUCT_NAME = Swish; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1269,7 +1241,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.thoughtbot.SwishTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1284,7 +1256,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.thoughtbot.SwishTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Swish.xcodeproj/xcshareddata/xcschemes/Swish-Mac.xcscheme b/Swish.xcodeproj/xcshareddata/xcschemes/Swish-Mac.xcscheme index 2d475d9..bf9efe7 100644 --- a/Swish.xcodeproj/xcshareddata/xcschemes/Swish-Mac.xcscheme +++ b/Swish.xcodeproj/xcshareddata/xcschemes/Swish-Mac.xcscheme @@ -1,6 +1,6 @@ - - diff --git a/Swish.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Swish.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Swish.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwishExamples.playground/Contents.swift b/SwishExamples.playground/Contents.swift index 712e9ad..352c63b 100644 --- a/SwishExamples.playground/Contents.swift +++ b/SwishExamples.playground/Contents.swift @@ -1,6 +1,5 @@ import PlaygroundSupport import Swish -import Result PlaygroundPage.current.needsIndefiniteExecution = true diff --git a/SwishExamples.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwishExamples.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwishExamples.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Tests/Fakes/FakeRequest.swift b/Tests/Fakes/FakeRequest.swift index acd407c..ff78358 100644 --- a/Tests/Fakes/FakeRequest.swift +++ b/Tests/Fakes/FakeRequest.swift @@ -1,6 +1,5 @@ import Foundation import Swish -import Result struct FakeRequest: Request { typealias ResponseObject = String diff --git a/Tests/Fakes/FakeRequestPerformer.swift b/Tests/Fakes/FakeRequestPerformer.swift index 1924078..ebad0e5 100644 --- a/Tests/Fakes/FakeRequestPerformer.swift +++ b/Tests/Fakes/FakeRequestPerformer.swift @@ -1,6 +1,5 @@ import Foundation import Swish -import Result enum ResponseData { case data(Data) diff --git a/Tests/Helpers/NimbleMatchers.swift b/Tests/Helpers/NimbleMatchers.swift index 0dc4d77..4fa41e5 100644 --- a/Tests/Helpers/NimbleMatchers.swift +++ b/Tests/Helpers/NimbleMatchers.swift @@ -1,5 +1,4 @@ import Nimble -import Result public func beVoid() -> MatcherFunc { return MatcherFunc { actualExpression, failureMessage in diff --git a/Tests/Tests/APIClientSpec.swift b/Tests/Tests/APIClientSpec.swift index 8361ec4..87d41a1 100644 --- a/Tests/Tests/APIClientSpec.swift +++ b/Tests/Tests/APIClientSpec.swift @@ -1,7 +1,6 @@ import Swish import Quick import Nimble -import Result class APIClientSpec: QuickSpec { override func spec() { @@ -32,8 +31,8 @@ class APIClientSpec: QuickSpec { var result: Result? client.perform(request) { result = $0 } - - expect(result?.value).toEventually(equal("hello world")) + + expect { try result?.get() }.toEventually(equal("hello world")) } } @@ -45,10 +44,12 @@ class APIClientSpec: QuickSpec { ) let client = APIClient(requestPerformer: performer) - var error: Error? + var error: SwishError? - client.perform(request) { - error = $0.error + client.perform(request) { result in + if case let .failure(resultError) = result { + error = resultError + } } expect(error).toEventually(matchError(SwishError.self)) @@ -66,8 +67,8 @@ class APIClientSpec: QuickSpec { var result: Result? client.perform(request) { result = $0 } - - expect(result?.value).toEventually(beVoid()) + + expect { try result?.get() }.toEventually(beVoid()) } } @@ -82,8 +83,8 @@ class APIClientSpec: QuickSpec { var result: Result? client.perform(request) { result = $0 } - - expect(result?.value).toEventually(beVoid()) + + expect { try result?.get() }.toEventually(beVoid()) } } } @@ -119,13 +120,13 @@ class APIClientSpec: QuickSpec { ) let client = APIClient(requestPerformer: performer) - var error: SwishError? - + var result: Result? + client.perform(request) { - error = $0.error + result = $0 } - - expect(error).toEventually(matchError(SwishError.serverError(code: expectedCode, data: performer.data))) + + expect { try result?.get() }.toEventually(throwError(SwishError.serverError(code: expectedCode, data: performer.data))) } } @@ -140,13 +141,13 @@ class APIClientSpec: QuickSpec { ) let client = APIClient(requestPerformer: performer) - var error: SwishError? + var result: Result? client.perform(request) { - error = $0.error + result = $0 } - expect(error).toEventually(matchError(SwishError.serverError(code: expectedCode, data: performer.data))) + expect { try result?.get() }.toEventually(throwError(SwishError.serverError(code: expectedCode, data: performer.data))) } } @@ -161,13 +162,13 @@ class APIClientSpec: QuickSpec { ) let client = APIClient(requestPerformer: performer) - var error: SwishError? + var result: Result? client.perform(request) { - error = $0.error + result = $0 } - - expect(error).toEventually(matchError(SwishError.serverError(code: expectedCode, data: performer.data))) + + expect { try result?.get() }.toEventually(throwError(SwishError.serverError(code: expectedCode, data: performer.data))) } } @@ -182,13 +183,13 @@ class APIClientSpec: QuickSpec { ) let client = APIClient(requestPerformer: performer) - var error: SwishError? - + var result: Result? + client.perform(request) { - error = $0.error + result = $0 } - - expect(error).toEventually(matchError(SwishError.serverError(code: expectedCode, data: performer.data))) + + expect { try result?.get() }.toEventually(throwError(SwishError.serverError(code: expectedCode, data: performer.data))) } } diff --git a/Tests/Tests/NetworkRequestPerformerSpec.swift b/Tests/Tests/NetworkRequestPerformerSpec.swift index b2afd59..de737e1 100644 --- a/Tests/Tests/NetworkRequestPerformerSpec.swift +++ b/Tests/Tests/NetworkRequestPerformerSpec.swift @@ -1,7 +1,6 @@ import Swish import Quick import Nimble -import Result func exampleRequest() -> URLRequest { return URLRequest(url: URL(string: "https://example.com")!) @@ -33,13 +32,14 @@ class RequestPerformerSpec: QuickSpec { context("when the request didn't produce an error") { it("returns a Result with the HTTPResponse") { let fakeSession = FakeSession(data: fakeData(), response: fakeResponse(200)) - var returnedCode: Int = 0 + var returnedCode: Int? var returnedData: Data? let performer = NetworkRequestPerformer(session: fakeSession) performer.perform(exampleRequest()) { result in - returnedCode = result.value!.code - returnedData = result.value!.data + let value = try? result.get() + returnedCode = value?.code + returnedData = value?.data } expect(returnedCode).to(equal(200)) @@ -55,7 +55,9 @@ class RequestPerformerSpec: QuickSpec { let performer = NetworkRequestPerformer(session: fakeSession) performer.perform(exampleRequest()) { result in - returnedError = result.error + if case .failure(let error) = result { + returnedError = error + } } expect(returnedError).to(matchError(SwishError.urlSessionError(error, response: nil))) diff --git a/Tests/Tests/RequestSpec.swift b/Tests/Tests/RequestSpec.swift index 69a8ab2..8cc80de 100644 --- a/Tests/Tests/RequestSpec.swift +++ b/Tests/Tests/RequestSpec.swift @@ -1,7 +1,6 @@ import Swish import Quick import Nimble -import Result struct User: Decodable { let name: String