From 2197489562dbbeef597c6d9b4eb9da863569f69e Mon Sep 17 00:00:00 2001 From: Bill Panagiotopoulos Date: Wed, 29 Dec 2021 10:38:02 +0200 Subject: [PATCH] Support Xcode 13.x (#26) --- .../Communication/Routers/CityRoute.swift | 16 +++---- README.md | 43 +++++++++--------- Source/Extensions/Request+ResponseTypes.swift | 4 +- Source/MultipartFormDataStream.swift | 2 +- Source/Reachability.swift | 2 +- Source/Request.swift | 2 +- TermiNetwork.xcodeproj/project.pbxproj | 28 +++++------- TermiNetworkLogo.svg | 6 ++- Tests/herokuapp.com.cer | Bin 1497 -> 1496 bytes 9 files changed, 50 insertions(+), 53 deletions(-) diff --git a/Examples/Communication/Routers/CityRoute.swift b/Examples/Communication/Routers/CityRoute.swift index ce7d879c..0c82c697 100644 --- a/Examples/Communication/Routers/CityRoute.swift +++ b/Examples/Communication/Routers/CityRoute.swift @@ -33,23 +33,23 @@ enum CityRoute: RouteProtocol { switch self { case .cities: return RouteConfiguration(method: .get, - path: .path(["cities"]), - mockFilePath: + path: .path(["cities"]), + mockFilePath: .path(["Cities", "cities.json"])) case .city(let id): return RouteConfiguration(method: .get, - path: .path(["city", String(id)]), - mockFilePath: + path: .path(["city", String(id)]), + mockFilePath: .path(["Cities", "Details", String(format: "%i.json", id)])) case .thumb(let city): return RouteConfiguration(method: .get, - path: .path([city.thumb ?? ""]), - mockFilePath: + path: .path([city.thumb ?? ""]), + mockFilePath: .path(["Cities", "Thumbs", String(format: "%i.jpg", city.cityID)])) case .image(let city): return RouteConfiguration(method: .get, - path: .path([city.image ?? ""]), - mockFilePath: + path: .path([city.image ?? ""]), + mockFilePath: .path(["Cities", "Images", String(format: "%i.jpg", city.cityID)])) case .pinning(let configuration): return RouteConfiguration( diff --git a/README.md b/README.md index 25702feb..48dfde22 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

- +

A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications. @@ -20,29 +20,28 @@

-🚀 TermiNetwork was tested in a production environment with a heavy load of asynchronous requests and tens of thousands of unique clients per day.

-
-

-

-This is a low resolution diagram of TermiNetwork that shows how its componets are connected to each other.

-
+🚀 TermiNetwork has been tested in a production environment with a heavy load of asynchronous requests and tens of thousands of unique clients per day. +

+ +This is a high level diagram of TermiNetwork showing how its componets are connected to each other. +

## Features -➡️  Multi-environment setup
-➡️  Model deserialization with Codables
-➡️  Choose the response type you want: Codable, UIImage, Data or String
-➡️  UIKit/SwiftUI helpers for downloading remote images
-➡️  Organize your Requests with Routers
-➡️  Reachability
-➡️  Transformers: convert REST models to DOMAIN models
-➡️  Error Handling
-➡️  Interceptors
-➡️  Mock Responses
-➡️  Certificate Pinning
-➡️  Flexible Configuration
-➡️  Middleware
-➡️  File/Data Upload/Download
-➡️  Pretty printed debug information +▫️ Multi-environment setup
+▫️ Model deserialization with Codables
+▫️ Decode response in the appropriate response type: Codable, UIImage, Data or String
+▫️ UIKit/SwiftUI helpers for downloading remote images
+▫️ Group your Requests in Routers
+▫️ Reachability support
+▫️ Transformers: convert models from one type to another easily
+▫️ Error Handling
+▫️ Interceptors
+▫️ Mock Responses
+▫️ Certificate Pinning
+▫️ Flexible Configuration
+▫️ Middleware
+▫️ File/Data Upload/Download
+▫️ Pretty printed debug information ### Table of contents - [Installation](#installation) diff --git a/Source/Extensions/Request+ResponseTypes.swift b/Source/Extensions/Request+ResponseTypes.swift index 8c135d9f..b69b3a53 100644 --- a/Source/Extensions/Request+ResponseTypes.swift +++ b/Source/Extensions/Request+ResponseTypes.swift @@ -24,7 +24,7 @@ extension Request { func makeResponseFailureHandler(responseHandler: @escaping (TNError) -> Void) -> (TNError, Data?, URLResponse?) -> Void { - return { error, data, urlResponse in + return { error, data, _ in self.handleDataTaskCompleted(with: data, error: error, onFailureCallback: { responseHandler(error) }) @@ -71,7 +71,7 @@ extension Request { func makeDecodableResponseFailureHandler(decodableType: T.Type, responseHandler: @escaping (T?, TNError) -> Void) -> (TNError, Data?, URLResponse?) -> Void { - return { error, data, urlResponse in + return { error, data, _ in // Check to see if there is already a deserialization error from success if case .cannotDeserialize = error { responseHandler(nil, error) diff --git a/Source/MultipartFormDataStream.swift b/Source/MultipartFormDataStream.swift index a0815630..23017968 100644 --- a/Source/MultipartFormDataStream.swift +++ b/Source/MultipartFormDataStream.swift @@ -221,7 +221,7 @@ internal class MultipartFormDataStream: NSObject, StreamDelegate { data.withUnsafeBytes { buffer in var maxLength = 0 - if case .stream(_, _) = currentBodyPart { + if case .stream = currentBodyPart { currentOffset = 0 maxLength = count < Constants.bufferSize ? count : Constants.bufferSize } else { diff --git a/Source/Reachability.swift b/Source/Reachability.swift index 7c3ed6e8..2fa427aa 100644 --- a/Source/Reachability.swift +++ b/Source/Reachability.swift @@ -113,7 +113,7 @@ open class Reachability { .passRetained(self) .toOpaque() - let callback: SCNetworkReachabilityCallBack = { (reachability, flags, info) in + let callback: SCNetworkReachabilityCallBack = { (_, flags, info) in guard let info = info else { return } Unmanaged.fromOpaque(info) diff --git a/Source/Request.swift b/Source/Request.swift index cfba7f89..11327be1 100644 --- a/Source/Request.swift +++ b/Source/Request.swift @@ -393,7 +393,7 @@ public final class Request: Operation { dataTask = SessionTaskFactory.makeDownloadTask(with: self, filePath: filePath, progressUpdate: progressUpdate, - completionHandler: { data, urlResponse in + completionHandler: { _, urlResponse in self.successCompletionHandler?(Data(), urlResponse) }, onFailure: { error, data in self.failureCompletionHandler?(error, data, self.urlResponse) diff --git a/TermiNetwork.xcodeproj/project.pbxproj b/TermiNetwork.xcodeproj/project.pbxproj index 8a5cdb10..61637f3e 100644 --- a/TermiNetwork.xcodeproj/project.pbxproj +++ b/TermiNetwork.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 23B36A0D277BB6D100A270B7 /* CryptoSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 23B36A0C277BB6D100A270B7 /* CryptoSwift */; }; F309C0ED25A512AB00D10877 /* Request+ResponseTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = F309C0EC25A512AB00D10877 /* Request+ResponseTypes.swift */; }; F30A298A258787320046C8E6 /* MiscRoute.swift in Sources */ = {isa = PBXBuildFile; fileRef = F30A2989258787320046C8E6 /* MiscRoute.swift */; }; F30A298E2587881D0046C8E6 /* RSEncryptedModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F30A298D258788180046C8E6 /* RSEncryptedModel.swift */; }; @@ -49,8 +50,6 @@ F32BB57B25A8ADCE00E6E096 /* StatusCodeTransformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F32BB57A25A8ADCE00E6E096 /* StatusCodeTransformer.swift */; }; F32C3D13243E499E004497BC /* TestPinning.swift in Sources */ = {isa = PBXBuildFile; fileRef = F32C3D12243E499E004497BC /* TestPinning.swift */; }; F3309DB4258AA05700BB018D /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F3309DB3258AA05700BB018D /* Launch Screen.storyboard */; }; - F3309DBF258ABF1200BB018D /* CryptoSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F3309DBE258ABF1200BB018D /* CryptoSwift */; }; - F3309DE7258AC45800BB018D /* CryptoSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F3309DE6258AC45800BB018D /* CryptoSwift */; }; F3319E9C246AD71C00D94AFE /* MultipartFormDataPartType.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3319E9B246AD71C00D94AFE /* MultipartFormDataPartType.swift */; }; F333429A25792E9D0087BDBA /* ErrorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F333429925792E9D0087BDBA /* ErrorModel.swift */; }; F3354D7825C737F600E02BC3 /* TestReachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3354D7725C737F600E02BC3 /* TestReachability.swift */; }; @@ -168,6 +167,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 23B36A07277BB5B800A270B7 /* CryptoKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CryptoKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/CryptoKit.framework; sourceTree = DEVELOPER_DIR; }; F309C0EC25A512AB00D10877 /* Request+ResponseTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Request+ResponseTypes.swift"; sourceTree = ""; }; F30A2986258783B40046C8E6 /* CryptoMiddleware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoMiddleware.swift; sourceTree = ""; }; F30A2989258787320046C8E6 /* MiscRoute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiscRoute.swift; sourceTree = ""; }; @@ -305,6 +305,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 23B36A0D277BB6D100A270B7 /* CryptoSwift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -313,7 +314,6 @@ buildActionMask = 2147483647; files = ( F3196837243D01E1008725CE /* TermiNetwork.framework in Frameworks */, - F3309DBF258ABF1200BB018D /* CryptoSwift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -322,7 +322,6 @@ buildActionMask = 2147483647; files = ( F3D16EC82575299900F7B523 /* TermiNetwork.framework in Frameworks */, - F3309DE7258AC45800BB018D /* CryptoSwift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -771,6 +770,7 @@ F3D16EC72575299900F7B523 /* Frameworks */ = { isa = PBXGroup; children = ( + 23B36A07277BB5B800A270B7 /* CryptoKit.framework */, F39474D725C8A1730084CB25 /* SystemConfiguration.framework */, ); name = Frameworks; @@ -815,6 +815,7 @@ ); name = TermiNetwork; packageProductDependencies = ( + 23B36A0C277BB6D100A270B7 /* CryptoSwift */, ); productName = TermiNetwork; productReference = F319682D243D01E1008725CE /* TermiNetwork.framework */; @@ -836,7 +837,6 @@ ); name = TermiNetworkTests; packageProductDependencies = ( - F3309DBE258ABF1200BB018D /* CryptoSwift */, ); productName = TermiNetworkTests; productReference = F3196836243D01E1008725CE /* TermiNetworkTests.xctest */; @@ -858,7 +858,6 @@ ); name = "TermiNetworkExamples (iOS)"; packageProductDependencies = ( - F3309DE6258AC45800BB018D /* CryptoSwift */, ); productName = "TermiNetworkExamples (iOS)"; productReference = F3556080257527C40047D46D /* TermiNetworkExamples.app */; @@ -897,7 +896,7 @@ ); mainGroup = F3196823243D01E1008725CE; packageReferences = ( - F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */, + 23B36A0B277BB6D100A270B7 /* XCRemoteSwiftPackageReference "CryptoSwift" */, ); productRefGroup = F319682E243D01E1008725CE /* Products */; projectDirPath = ""; @@ -959,7 +958,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\n swiftlint --path \"$PROJECT_DIR/Source\" --config \"$PROJECT_DIR/.swiftlint.yml\"\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + shellScript = "export PATH=\"/opt/homebrew/bin/:$PATH\"\nif which swiftlint >/dev/null; then\n swiftlint --path \"$PROJECT_DIR/Source\" --config \"$PROJECT_DIR/.swiftlint.yml\"\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; F3196885243D0904008725CE /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -1443,25 +1442,20 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */ = { + 23B36A0B277BB6D100A270B7 /* XCRemoteSwiftPackageReference "CryptoSwift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/krzyzanowskim/CryptoSwift"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 1.3.8; + minimumVersion = 1.0.0; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - F3309DBE258ABF1200BB018D /* CryptoSwift */ = { + 23B36A0C277BB6D100A270B7 /* CryptoSwift */ = { isa = XCSwiftPackageProductDependency; - package = F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */; - productName = CryptoSwift; - }; - F3309DE6258AC45800BB018D /* CryptoSwift */ = { - isa = XCSwiftPackageProductDependency; - package = F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */; + package = 23B36A0B277BB6D100A270B7 /* XCRemoteSwiftPackageReference "CryptoSwift" */; productName = CryptoSwift; }; /* End XCSwiftPackageProductDependency section */ diff --git a/TermiNetworkLogo.svg b/TermiNetworkLogo.svg index 3374560d..dbd452b4 100644 --- a/TermiNetworkLogo.svg +++ b/TermiNetworkLogo.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/Tests/herokuapp.com.cer b/Tests/herokuapp.com.cer index 063eb69aa73a9c2449a54496c5a8c55452faf494..cc97c4d558f25d198e17e2577ec0d5e54281e435 100644 GIT binary patch delta 925 zcmV;O17iHy3)l-EFoFftFoFcUpaTK{0s;^ZjvH@6@N(ebL=jWcpBNvJA6^nRFflMN zFfcGMS{Ds6GB7qXFp-Z$f2g5f=Ek26{Gs4Fp+m;wHg||}hp*#~cStpPDb2D429+g= zZiCy(?BQB77Nnq9Hro+`%v6CmsB{9H@$NmVh{iE!Z@)aQ1|-DJOK za4Bxb`ZGS}|3{Ql2u*o-HOTc}?DKNOxd*;dqkJ$2uC8;BL z*xb{Pl+MfR;|;^d4@+H1_~<%0R#coc>)9i1cCu>1cCu-0cew411D3+kr~ba00aX7M=(VKAppZW ziYQ)RIGGfY8ryFXXF|aN+H7x=lI*$uZjdWhc%`sa15gh7=za~oZ z=kg|oPDqgNSG1A30Ctns10_+&ks2QW00aX7M=(VKAZr)q*1q&R^`K4lPt;>(zToS^ zCNeibd8{X8r2h}GU;-fk!`pfc(}r)K7-xa~D}>4q*uV1!j|__nvD63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