From e858c8ad022dc954a5e515967d41ce8557f809c4 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 25 Aug 2017 12:31:06 +0300 Subject: [PATCH 1/2] Add. Network extensions --- LeadKitAdditions.podspec | 2 +- .../project.pbxproj | 14 +++++++++++-- LeadKitAdditions/Podfile.lock | 4 ++-- .../Error+NetworkingExtensions.swift | 20 +++++++++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 LeadKitAdditions/Sources/Extensions/Error+NetworkingExtensions.swift diff --git a/LeadKitAdditions.podspec b/LeadKitAdditions.podspec index dfc9623..6f8524e 100644 --- a/LeadKitAdditions.podspec +++ b/LeadKitAdditions.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKitAdditions" - s.version = "0.0.21" + s.version = "0.0.22" s.summary = "iOS framework with a bunch of tools for rapid development" s.homepage = "https://github.com/TouchInstinct/LeadKitAdditions" s.license = "Apache License, Version 2.0" diff --git a/LeadKitAdditions/LeadKitAdditions.xcodeproj/project.pbxproj b/LeadKitAdditions/LeadKitAdditions.xcodeproj/project.pbxproj index d511837..0b469fa 100644 --- a/LeadKitAdditions/LeadKitAdditions.xcodeproj/project.pbxproj +++ b/LeadKitAdditions/LeadKitAdditions.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 0A08E37F1F2A13BF00F9AB62 /* CellTextFieldToolBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A08E37E1F2A13BF00F9AB62 /* CellTextFieldToolBar.swift */; }; 248389A288C0A6D7914F0546 /* Pods_LeadKitAdditions_LeadKitAdditions_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0ED4A1B793EAA73C9E95969F /* Pods_LeadKitAdditions_LeadKitAdditions_iOS.framework */; }; + A6CFB8D91F5024A500A42CC2 /* Error+NetworkingExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6CFB8D81F5024A500A42CC2 /* Error+NetworkingExtensions.swift */; }; B326804BA6CC8B8BB136A46A /* Pods_LeadKitAdditions_LeadKitAdditions_iOS_Extensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CFD5627139CAB27705F75C07 /* Pods_LeadKitAdditions_LeadKitAdditions_iOS_Extensions.framework */; }; CAE698E81E968820000394B0 /* LeadKitAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE698E61E968820000394B0 /* LeadKitAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; ED0C34031F2906EC00FAE9FD /* ApiResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33D31F2906EC00FAE9FD /* ApiResponse.swift */; }; @@ -90,6 +91,7 @@ 49738551AC648B0AFA74E57F /* Pods-LeadKitAdditions-LeadKitAdditions iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKitAdditions-LeadKitAdditions iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKitAdditions-LeadKitAdditions iOS/Pods-LeadKitAdditions-LeadKitAdditions iOS.debug.xcconfig"; sourceTree = ""; }; 7B7F57C5E5275C4D8DC71992 /* Pods_LeadKitAdditions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKitAdditions.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9D549FA5A7579702358E07DF /* Pods-LeadKitAdditions-LeadKitAdditions iOS Extensions.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKitAdditions-LeadKitAdditions iOS Extensions.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKitAdditions-LeadKitAdditions iOS Extensions/Pods-LeadKitAdditions-LeadKitAdditions iOS Extensions.debug.xcconfig"; sourceTree = ""; }; + A6CFB8D81F5024A500A42CC2 /* Error+NetworkingExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Error+NetworkingExtensions.swift"; sourceTree = ""; }; CAE698E31E968820000394B0 /* LeadKitAdditions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LeadKitAdditions.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CAE698E61E968820000394B0 /* LeadKitAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LeadKitAdditions.h; sourceTree = ""; }; CFD5627139CAB27705F75C07 /* Pods_LeadKitAdditions_LeadKitAdditions_iOS_Extensions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKitAdditions_LeadKitAdditions_iOS_Extensions.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -272,6 +274,7 @@ ED0C33E71F2906EC00FAE9FD /* Observable+Extensions.swift */, ED0C33E81F2906EC00FAE9FD /* UIBarButtonItem+Extensions.swift */, ED0C33E91F2906EC00FAE9FD /* UserDefaults+UserService.swift */, + A6CFB8D81F5024A500A42CC2 /* Error+NetworkingExtensions.swift */, ); path = Extensions; sourceTree = ""; @@ -478,13 +481,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-LeadKitAdditions-LeadKitAdditions iOS Extensions-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 808FF5474C0E1574D405EFAF /* [CP] Copy Pods Resources */ = { @@ -537,13 +543,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-LeadKitAdditions-LeadKitAdditions iOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; ED69E7E91F2AD0E000C74895 /* Swiftlint */ = { @@ -591,6 +600,7 @@ ED0C34291F2906EC00FAE9FD /* CellFieldValidationProtocol.swift in Sources */, 0A08E37F1F2A13BF00F9AB62 /* CellTextFieldToolBar.swift in Sources */, ED0C34031F2906EC00FAE9FD /* ApiResponse.swift in Sources */, + A6CFB8D91F5024A500A42CC2 /* Error+NetworkingExtensions.swift in Sources */, ED0C34071F2906EC00FAE9FD /* LoadingBarButton.swift in Sources */, ED0C34251F2906EC00FAE9FD /* CellFieldMaskProtocol.swift in Sources */, ED0C34211F2906EC00FAE9FD /* UserDefaults+UserService.swift in Sources */, diff --git a/LeadKitAdditions/Podfile.lock b/LeadKitAdditions/Podfile.lock index 386fbaf..d1004ab 100644 --- a/LeadKitAdditions/Podfile.lock +++ b/LeadKitAdditions/Podfile.lock @@ -50,7 +50,7 @@ SPEC CHECKSUMS: InputMask: fe1da1c6bf39133d88c1f79c507bcb0bf7728d51 KeychainAccess: a986406022dfc7c634c691ad3bec670cc6a32002 LeadKit: a66ca7c85b3e33deb11b6544fa80f45c9f0044e4 - ObjectMapper: '042708195cc46c20871cbcbec0453826398273fd' + ObjectMapper: 042708195cc46c20871cbcbec0453826398273fd RxAlamofire: bc53604b29fd2d220cfaa490c736cc4500819f34 RxCocoa: d14ef6b6029e1ddc6e966508c09289090de68ff9 RxSwift: 3789a1af753002a14edecdb698a2424624296a9c @@ -60,4 +60,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 6f750f6723897b213ed701c061a4f70baaeb4d54 -COCOAPODS: 1.2.1 +COCOAPODS: 1.3.1 diff --git a/LeadKitAdditions/Sources/Extensions/Error+NetworkingExtensions.swift b/LeadKitAdditions/Sources/Extensions/Error+NetworkingExtensions.swift new file mode 100644 index 0000000..b5767b4 --- /dev/null +++ b/LeadKitAdditions/Sources/Extensions/Error+NetworkingExtensions.swift @@ -0,0 +1,20 @@ +import Foundation + +/// Extension for network Error classification +public extension Error { + + /// Returns: TRUE if error is connection error + var isConnectionError: Bool { + guard let urlError = self as? URLError else { + return false + } + + return urlError.code == .notConnectedToInternet || urlError.code == .timedOut + } + + /// Returns: TRUE if server json response is not valid + var isResponseSerializationError: Bool { + return (self as? AFError)?.isResponseSerializationError ?? false + } + +} From 6d51a8e0f5cda113c7e91f7c7a88561fb8085a26 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 25 Aug 2017 12:39:21 +0300 Subject: [PATCH 2/2] Fix capitalization --- .../Sources/Extensions/Error+NetworkingExtensions.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LeadKitAdditions/Sources/Extensions/Error+NetworkingExtensions.swift b/LeadKitAdditions/Sources/Extensions/Error+NetworkingExtensions.swift index b5767b4..45ebe0d 100644 --- a/LeadKitAdditions/Sources/Extensions/Error+NetworkingExtensions.swift +++ b/LeadKitAdditions/Sources/Extensions/Error+NetworkingExtensions.swift @@ -3,7 +3,7 @@ import Foundation /// Extension for network Error classification public extension Error { - /// Returns: TRUE if error is connection error + /// Returns: true if error is connection error var isConnectionError: Bool { guard let urlError = self as? URLError else { return false @@ -12,7 +12,7 @@ public extension Error { return urlError.code == .notConnectedToInternet || urlError.code == .timedOut } - /// Returns: TRUE if server json response is not valid + /// Returns: true if server json response is not valid var isResponseSerializationError: Bool { return (self as? AFError)?.isResponseSerializationError ?? false }