From 72cd6846aa8d243b23cbbb84e59e6a985e54a750 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sat, 9 Nov 2019 21:12:38 +0000 Subject: [PATCH] Update dependencies, test with Xcode 10.3 (#14) Close #9 Close #10 Close #12 --- .gitignore | 2 +- .travis.yml | 22 +- ApolloAlamofire.podspec | 6 +- .../Classes/AlamofireTransport.swift | 26 +- Cartfile | 4 +- Cartfile.resolved | 6 +- Example/Podfile.lock | 22 +- Example/Pods/Alamofire/LICENSE | 19 - Example/Pods/Alamofire/README.md | 243 ---- Example/Pods/Alamofire/Source/AFError.swift | 460 ------- Example/Pods/Alamofire/Source/Alamofire.swift | 465 ------- .../Source/DispatchQueue+Alamofire.swift | 37 - .../Alamofire/Source/MultipartFormData.swift | 580 -------- .../Source/NetworkReachabilityManager.swift | 235 ---- .../Pods/Alamofire/Source/Notifications.swift | 55 - .../Alamofire/Source/ParameterEncoding.swift | 483 ------- Example/Pods/Alamofire/Source/Request.swift | 649 --------- Example/Pods/Alamofire/Source/Response.swift | 567 -------- .../Source/ResponseSerialization.swift | 715 ---------- Example/Pods/Alamofire/Source/Result.swift | 300 ---- .../Alamofire/Source/ServerTrustPolicy.swift | 307 ----- .../Alamofire/Source/SessionDelegate.swift | 725 ---------- .../Alamofire/Source/SessionManager.swift | 899 ------------ .../Pods/Alamofire/Source/TaskDelegate.swift | 466 ------- Example/Pods/Alamofire/Source/Timeline.swift | 136 -- .../Pods/Alamofire/Source/Validation.swift | 315 ----- Example/Pods/Apollo/LICENSE | 21 - Example/Pods/Apollo/README.md | 32 - .../Apollo/Sources/Apollo/ApolloClient.swift | 249 ---- .../Apollo/Sources/Apollo/ApolloStore.swift | 249 ---- .../Apollo/AsynchronousOperation.swift | 47 - .../Apollo/Sources/Apollo/Collections.swift | 100 -- .../Apollo/Sources/Apollo/DataLoader.swift | 57 - .../Apollo/GraphQLDependencyTracker.swift | 26 - .../Apollo/Sources/Apollo/GraphQLError.swift | 62 - .../Sources/Apollo/GraphQLExecutor.swift | 286 ---- .../Sources/Apollo/GraphQLInputValue.swift | 104 -- .../Sources/Apollo/GraphQLOperation.swift | 52 - .../Sources/Apollo/GraphQLQueryWatcher.swift | 54 - .../Sources/Apollo/GraphQLResponse.swift | 40 - .../Apollo/GraphQLResponseGenerator.swift | 27 - .../Apollo/Sources/Apollo/GraphQLResult.swift | 25 - .../Apollo/GraphQLResultAccumulator.swift | 108 -- .../Apollo/GraphQLResultNormalizer.swift | 34 - .../Sources/Apollo/GraphQLSelectionSet.swift | 128 -- .../Apollo/GraphQLSelectionSetMapper.swift | 27 - .../Sources/Apollo/HTTPNetworkTransport.swift | 132 -- .../Apollo/InMemoryNormalizedCache.swift | 21 - Example/Pods/Apollo/Sources/Apollo/JSON.swift | 60 - .../Apollo/JSONSerializationFormat.swift | 11 - .../Apollo/JSONStandardTypeConversions.swift | 158 --- .../Pods/Apollo/Sources/Apollo/Locking.swift | 69 - .../Sources/Apollo/NetworkTransport.swift | 13 - .../Sources/Apollo/NormalizedCache.swift | 16 - .../Pods/Apollo/Sources/Apollo/Promise.swift | 260 ---- .../Pods/Apollo/Sources/Apollo/Record.swift | 52 - .../Apollo/Sources/Apollo/RecordSet.swift | 81 -- .../Pods/Apollo/Sources/Apollo/Result.swift | 44 - .../Sources/Apollo/ResultOrPromise.swift | 152 --- .../Apollo/Sources/Apollo/Utilities.swift | 23 - .../scripts/check-and-run-apollo-cli.sh | 90 -- .../scripts/check-and-run-apollo-codegen.sh | 2 - .../ApolloAlamofire.podspec.json | 32 - Example/Pods/Manifest.lock | 29 - Example/Pods/Pods.xcodeproj/project.pbxproj | 1205 ----------------- .../contents.xcworkspacedata | 7 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../xcschemes/ApolloAlamofire.xcscheme | 80 -- .../Alamofire/Alamofire-Info.plist | 26 - .../Alamofire/Alamofire-dummy.m | 5 - .../Alamofire/Alamofire-prefix.pch | 12 - .../Alamofire/Alamofire-umbrella.h | 16 - .../Alamofire/Alamofire.modulemap | 6 - .../Alamofire/Alamofire.xcconfig | 9 - .../Target Support Files/Alamofire/Info.plist | 26 - .../Apollo/Apollo-Info.plist | 26 - .../Apollo/Apollo-dummy.m | 5 - .../Apollo/Apollo-prefix.pch | 12 - .../Apollo/Apollo-umbrella.h | 16 - .../Apollo/Apollo.modulemap | 6 - .../Apollo/Apollo.xcconfig | 9 - .../Target Support Files/Apollo/Info.plist | 26 - .../ApolloAlamofire-Info.plist | 26 - .../ApolloAlamofire/ApolloAlamofire-dummy.m | 5 - .../ApolloAlamofire-prefix.pch | 12 - .../ApolloAlamofire-umbrella.h | 16 - .../ApolloAlamofire/ApolloAlamofire.modulemap | 6 - .../ApolloAlamofire/ApolloAlamofire.xcconfig | 10 - .../ApolloAlamofire/Info.plist | 26 - .../Pods-ExampleTests-Info.plist | 26 - ...ods-ExampleTests-acknowledgements.markdown | 74 - .../Pods-ExampleTests-acknowledgements.plist | 118 -- .../Pods-ExampleTests-dummy.m | 5 - .../Pods-ExampleTests-frameworks.sh | 175 --- .../Pods-ExampleTests-umbrella.h | 16 - .../Pods-ExampleTests.debug.xcconfig | 11 - .../Pods-ExampleTests.modulemap | 6 - .../Pods-ExampleTests.release.xcconfig | 11 - build.sh | 9 + 99 files changed, 57 insertions(+), 12712 deletions(-) delete mode 100644 Example/Pods/Alamofire/LICENSE delete mode 100644 Example/Pods/Alamofire/README.md delete mode 100644 Example/Pods/Alamofire/Source/AFError.swift delete mode 100644 Example/Pods/Alamofire/Source/Alamofire.swift delete mode 100644 Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift delete mode 100644 Example/Pods/Alamofire/Source/MultipartFormData.swift delete mode 100644 Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift delete mode 100644 Example/Pods/Alamofire/Source/Notifications.swift delete mode 100644 Example/Pods/Alamofire/Source/ParameterEncoding.swift delete mode 100644 Example/Pods/Alamofire/Source/Request.swift delete mode 100644 Example/Pods/Alamofire/Source/Response.swift delete mode 100644 Example/Pods/Alamofire/Source/ResponseSerialization.swift delete mode 100644 Example/Pods/Alamofire/Source/Result.swift delete mode 100644 Example/Pods/Alamofire/Source/ServerTrustPolicy.swift delete mode 100644 Example/Pods/Alamofire/Source/SessionDelegate.swift delete mode 100644 Example/Pods/Alamofire/Source/SessionManager.swift delete mode 100644 Example/Pods/Alamofire/Source/TaskDelegate.swift delete mode 100644 Example/Pods/Alamofire/Source/Timeline.swift delete mode 100644 Example/Pods/Alamofire/Source/Validation.swift delete mode 100644 Example/Pods/Apollo/LICENSE delete mode 100644 Example/Pods/Apollo/README.md delete mode 100644 Example/Pods/Apollo/Sources/Apollo/ApolloClient.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/ApolloStore.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/AsynchronousOperation.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/Collections.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/DataLoader.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLDependencyTracker.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLError.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLExecutor.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLInputValue.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLOperation.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLQueryWatcher.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLResponse.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLResponseGenerator.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLResult.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLResultAccumulator.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLResultNormalizer.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLSelectionSet.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/GraphQLSelectionSetMapper.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/HTTPNetworkTransport.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/InMemoryNormalizedCache.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/JSON.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/JSONSerializationFormat.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/JSONStandardTypeConversions.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/Locking.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/NetworkTransport.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/NormalizedCache.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/Promise.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/Record.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/RecordSet.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/Result.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/ResultOrPromise.swift delete mode 100644 Example/Pods/Apollo/Sources/Apollo/Utilities.swift delete mode 100755 Example/Pods/Apollo/scripts/check-and-run-apollo-cli.sh delete mode 100755 Example/Pods/Apollo/scripts/check-and-run-apollo-codegen.sh delete mode 100644 Example/Pods/Local Podspecs/ApolloAlamofire.podspec.json delete mode 100644 Example/Pods/Manifest.lock delete mode 100644 Example/Pods/Pods.xcodeproj/project.pbxproj delete mode 100644 Example/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 Example/Pods/Pods.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/ApolloAlamofire.xcscheme delete mode 100644 Example/Pods/Target Support Files/Alamofire/Alamofire-Info.plist delete mode 100644 Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m delete mode 100644 Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch delete mode 100644 Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h delete mode 100644 Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap delete mode 100644 Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig delete mode 100644 Example/Pods/Target Support Files/Alamofire/Info.plist delete mode 100644 Example/Pods/Target Support Files/Apollo/Apollo-Info.plist delete mode 100644 Example/Pods/Target Support Files/Apollo/Apollo-dummy.m delete mode 100644 Example/Pods/Target Support Files/Apollo/Apollo-prefix.pch delete mode 100644 Example/Pods/Target Support Files/Apollo/Apollo-umbrella.h delete mode 100644 Example/Pods/Target Support Files/Apollo/Apollo.modulemap delete mode 100644 Example/Pods/Target Support Files/Apollo/Apollo.xcconfig delete mode 100644 Example/Pods/Target Support Files/Apollo/Info.plist delete mode 100644 Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-Info.plist delete mode 100644 Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-dummy.m delete mode 100644 Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-prefix.pch delete mode 100644 Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-umbrella.h delete mode 100644 Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire.modulemap delete mode 100644 Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire.xcconfig delete mode 100644 Example/Pods/Target Support Files/ApolloAlamofire/Info.plist delete mode 100644 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-Info.plist delete mode 100644 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-acknowledgements.markdown delete mode 100644 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-acknowledgements.plist delete mode 100644 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-dummy.m delete mode 100755 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-frameworks.sh delete mode 100644 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-umbrella.h delete mode 100644 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.debug.xcconfig delete mode 100644 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.modulemap delete mode 100644 Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.release.xcconfig create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index 5f91235..2110b13 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,4 @@ Carthage/Build # Note: if you ignore the Pods directory, make sure to uncomment # `pod install` in .travis.yml # -# Pods/ +Example/Pods diff --git a/.travis.yml b/.travis.yml index 4e96db5..e57a52d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,19 +4,13 @@ matrix: include: - - osx_image: xcode10.2 + - osx_image: xcode10.3 language: swift - env: TEST_DEVICE='platform=iOS Simulator,OS=12.2,name=iPhone SE' + env: TEST_DEVICE='platform=iOS Simulator,OS=12.4,name=iPhone SE' -# cache: cocoapods -# podfile: Example/Podfile -# before_install: -# - gem install cocoapods # Since Travis is not always on latest version -# - pod install --project-directory=Example -script: - - > - set -o pipefail && xcodebuild test -enableCodeCoverage YES - -workspace Example/ApolloAlamofire.xcworkspace -scheme Example - -sdk iphonesimulator -destination "$TEST_DEVICE" | xcpretty - - pod repo update - - pod lib lint --allow-warnings +cache: cocoapods +podfile: Example/Podfile +before_install: + # - gem install cocoapods # Since Travis is not always on latest version + - pod install --repo-update --project-directory=Example +script: ./build.sh diff --git a/ApolloAlamofire.podspec b/ApolloAlamofire.podspec index 4bd5cf8..899ad19 100644 --- a/ApolloAlamofire.podspec +++ b/ApolloAlamofire.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |s| # * Write the description between the DESC delimiters below. # * Finally, don't worry about the indent, CocoaPods strips it! - s.swift_version = '4.2' + s.swift_versions = ['4.2', '5.0', '5.1'] s.description = <<-DESC This package bundles a `NetworkTransport` implementation that wraps Alamofire and solves known limitations of Apollo iOS library. @@ -40,6 +40,6 @@ and solves known limitations of Apollo iOS library. # s.public_header_files = 'Pod/Classes/**/*.h' # s.frameworks = 'UIKit', 'MapKit' - s.dependency 'Alamofire', '~> 4.8.2' - s.dependency 'Apollo', '~> 0.10.1' + s.dependency 'Alamofire', '~> 4.9.1' + s.dependency 'Apollo', '~> 0.19.0' end diff --git a/ApolloAlamofire/Classes/AlamofireTransport.swift b/ApolloAlamofire/Classes/AlamofireTransport.swift index f8baf47..22b9ef2 100644 --- a/ApolloAlamofire/Classes/AlamofireTransport.swift +++ b/ApolloAlamofire/Classes/AlamofireTransport.swift @@ -17,18 +17,28 @@ public class AlamofireTransport: NetworkTransport { let url: URL public var headers: HTTPHeaders? public var loggingEnabled: Bool + public var clientName: String + public var clientVersion: String - public init(url: URL, sessionManager: SessionManager = SessionManager.default, - headers: HTTPHeaders? = nil, loggingEnabled: Bool = false) { + public init( + url: URL, + sessionManager: SessionManager = SessionManager.default, + headers: HTTPHeaders? = nil, + loggingEnabled: Bool = false, + clientName: String = "ApolloAlamofire", + clientVersion: String = "0.5.0" + ) { self.sessionManager = sessionManager self.url = url self.headers = headers self.loggingEnabled = loggingEnabled + self.clientName = clientName + self.clientVersion = clientVersion } public func send( operation: Operation, - completionHandler: @escaping (GraphQLResponse?, Error?) -> () + completionHandler: @escaping (Swift.Result, Error>) -> () ) -> Cancellable where Operation: GraphQLOperation { let vars: JSONEncodable = operation.variables?.mapValues { $0?.jsonValue } @@ -44,7 +54,7 @@ public class AlamofireTransport: NetworkTransport { debugPrint(request) } return request.responseJSON { response in - let gqlResult = response.result + let result = response.result .flatMap { value -> GraphQLResponse in guard let value = value as? JSONObject else { throw response.error! @@ -55,7 +65,13 @@ public class AlamofireTransport: NetworkTransport { } return GraphQLResponse(operation: operation, body: value) } - completionHandler(gqlResult.value, gqlResult.error) + + switch result { + case let .failure(error): + completionHandler(.failure(error)) + case let .success(value): + completionHandler(.success(value)) + } }.task! } } diff --git a/Cartfile b/Cartfile index b603c36..c11d7ca 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,2 @@ -github "apollographql/apollo-ios" ~> 0.10.1 -github "Alamofire/Alamofire" ~> 4.8.2 +github "apollographql/apollo-ios" ~> 0.19.0 +github "Alamofire/Alamofire" ~> 4.9.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index 42fd3d4..6299cba 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,2 @@ -github "Alamofire/Alamofire" "4.8.2" -github "apollographql/apollo-ios" "0.10.1" -github "daltoniam/Starscream" "3.1.0" -github "stephencelis/SQLite.swift" "0.11.5" +github "Alamofire/Alamofire" "4.9.1" +github "apollographql/apollo-ios" "0.19.0" diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 7c3956d..104c84d 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,17 +1,17 @@ PODS: - - Alamofire (4.8.2) - - Apollo (0.10.1): - - Apollo/Core (= 0.10.1) - - Apollo/Core (0.10.1) + - Alamofire (4.9.1) + - Apollo (0.19.0): + - Apollo/Core (= 0.19.0) + - Apollo/Core (0.19.0) - ApolloAlamofire (0.5.0): - - Alamofire (~> 4.8.2) - - Apollo (~> 0.10.1) + - Alamofire (~> 4.9.1) + - Apollo (~> 0.19.0) DEPENDENCIES: - ApolloAlamofire (from `../`) SPEC REPOS: - https://github.com/cocoapods/specs.git: + https://github.com/CocoaPods/Specs.git: - Alamofire - Apollo @@ -20,10 +20,10 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3 - Apollo: 4d690a9b2e48e8820182df4b988d7a253e1ee589 - ApolloAlamofire: cb21686240a36b3500f3dbd318c88cfd14d15d77 + Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18 + Apollo: 4f0fea775a98bba34935764e49d27f2d3b1a5f21 + ApolloAlamofire: 450e37668e395d2e5e90d9c7ca5e285916479981 PODFILE CHECKSUM: 3d8d02ef1af8e9f3ad5f5d2ba9652a1dafc83875 -COCOAPODS: 1.7.3 +COCOAPODS: 1.8.4 diff --git a/Example/Pods/Alamofire/LICENSE b/Example/Pods/Alamofire/LICENSE deleted file mode 100644 index 38a301a..0000000 --- a/Example/Pods/Alamofire/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -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. diff --git a/Example/Pods/Alamofire/README.md b/Example/Pods/Alamofire/README.md deleted file mode 100644 index 26e364a..0000000 --- a/Example/Pods/Alamofire/README.md +++ /dev/null @@ -1,243 +0,0 @@ -![Alamofire: Elegant Networking in Swift](https://raw.githubusercontent.com/Alamofire/Alamofire/master/alamofire.png) - -[![Build Status](https://travis-ci.org/Alamofire/Alamofire.svg?branch=master)](https://travis-ci.org/Alamofire/Alamofire) -[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Alamofire.svg)](https://img.shields.io/cocoapods/v/Alamofire.svg) -[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) -[![Platform](https://img.shields.io/cocoapods/p/Alamofire.svg?style=flat)](https://alamofire.github.io/Alamofire) -[![Twitter](https://img.shields.io/badge/twitter-@AlamofireSF-blue.svg?style=flat)](https://twitter.com/AlamofireSF) -[![Gitter](https://badges.gitter.im/Alamofire/Alamofire.svg)](https://gitter.im/Alamofire/Alamofire?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - -Alamofire is an HTTP networking library written in Swift. - -- [Features](#features) -- [Component Libraries](#component-libraries) -- [Requirements](#requirements) -- [Migration Guides](#migration-guides) -- [Communication](#communication) -- [Installation](#installation) -- [Usage](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md) - - **Intro -** [Making a Request](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#making-a-request), [Response Handling](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-handling), [Response Validation](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-validation), [Response Caching](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#response-caching) - - **HTTP -** [HTTP Methods](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#http-methods), [Parameter Encoding](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#parameter-encoding), [HTTP Headers](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#http-headers), [Authentication](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#authentication) - - **Large Data -** [Downloading Data to a File](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#downloading-data-to-a-file), [Uploading Data to a Server](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#uploading-data-to-a-server) - - **Tools -** [Statistical Metrics](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#statistical-metrics), [cURL Command Output](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#curl-command-output) -- [Advanced Usage](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md) - - **URL Session -** [Session Manager](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md#session-manager), [Session Delegate](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md#session-delegate), [Request](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md#request) - - **Routing -** [Routing Requests](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md#routing-requests), [Adapting and Retrying Requests](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md#adapting-and-retrying-requests) - - **Model Objects -** [Custom Response Serialization](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md#custom-response-serialization) - - **Connection -** [Security](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md#security), [Network Reachability](https://github.com/Alamofire/Alamofire/blob/master/Documentation/AdvancedUsage.md#network-reachability) -- [Open Radars](#open-radars) -- [FAQ](#faq) -- [Credits](#credits) -- [Donations](#donations) -- [License](#license) - -## Features - -- [x] Chainable Request / Response Methods -- [x] URL / JSON / plist Parameter Encoding -- [x] Upload File / Data / Stream / MultipartFormData -- [x] Download File using Request or Resume Data -- [x] Authentication with URLCredential -- [x] HTTP Response Validation -- [x] Upload and Download Progress Closures with Progress -- [x] cURL Command Output -- [x] Dynamically Adapt and Retry Requests -- [x] TLS Certificate and Public Key Pinning -- [x] Network Reachability -- [x] Comprehensive Unit and Integration Test Coverage -- [x] [Complete Documentation](https://alamofire.github.io/Alamofire) - -## Component Libraries - -In order to keep Alamofire focused specifically on core networking implementations, additional component libraries have been created by the [Alamofire Software Foundation](https://github.com/Alamofire/Foundation) to bring additional functionality to the Alamofire ecosystem. - -- [AlamofireImage](https://github.com/Alamofire/AlamofireImage) - An image library including image response serializers, `UIImage` and `UIImageView` extensions, custom image filters, an auto-purging in-memory cache and a priority-based image downloading system. -- [AlamofireNetworkActivityIndicator](https://github.com/Alamofire/AlamofireNetworkActivityIndicator) - Controls the visibility of the network activity indicator on iOS using Alamofire. It contains configurable delay timers to help mitigate flicker and can support `URLSession` instances not managed by Alamofire. - -## Requirements - -- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ -- Xcode 8.3+ -- Swift 3.1+ - -## Migration Guides - -- [Alamofire 4.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md) -- [Alamofire 3.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%203.0%20Migration%20Guide.md) -- [Alamofire 2.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%202.0%20Migration%20Guide.md) - -## Communication -- If you **need help with making network requests**, use [Stack Overflow](https://stackoverflow.com/questions/tagged/alamofire) and tag `alamofire`. -- If you need to **find or understand an API**, check [our documentation](http://alamofire.github.io/Alamofire/) or [Apple's documentation for `URLSession`](https://developer.apple.com/documentation/foundation/url_loading_system), on top of which Alamofire is built. -- If you need **help with an Alamofire feature**, use [our forum on swift.org](https://forums.swift.org/c/related-projects/alamofire). -- If you'd like to **discuss Alamofire best practices**, use [our forum on swift.org](https://forums.swift.org/c/related-projects/alamofire). -- If you'd like to **discuss a feature request**, use [our forum on swift.org](https://forums.swift.org/c/related-projects/alamofire). -- If you **found a bug**, open an issue and follow the guide. The more detail the better! -- If you **want to contribute**, submit a pull request. - -## Installation - -### CocoaPods - -[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: - -```bash -$ gem install cocoapods -``` - -> CocoaPods 1.1+ is required to build Alamofire 4.0+. - -To integrate Alamofire into your Xcode project using CocoaPods, specify it in your `Podfile`: - -```ruby -source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '10.0' -use_frameworks! - -target '' do - pod 'Alamofire', '~> 4.7' -end -``` - -Then, run the following command: - -```bash -$ pod install -``` - -### Carthage - -[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. - -You can install Carthage with [Homebrew](https://brew.sh/) using the following command: - -```bash -$ brew update -$ brew install carthage -``` - -To integrate Alamofire into your Xcode project using Carthage, specify it in your `Cartfile`: - -```ogdl -github "Alamofire/Alamofire" ~> 4.7 -``` - -Run `carthage update` to build the framework and drag the built `Alamofire.framework` into your Xcode project. - -### Swift Package Manager - -The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but Alamofire does support its use on supported platforms. - -Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. - -#### Swift 3 - -```swift -dependencies: [ - .Package(url: "https://github.com/Alamofire/Alamofire.git", majorVersion: 4) -] -``` - -#### Swift 4 - -```swift -dependencies: [ - .package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.0.0") -] -``` - -### Manually - -If you prefer not to use any of the aforementioned dependency managers, you can integrate Alamofire into your project manually. - -#### Embedded Framework - -- Open up Terminal, `cd` into your top-level project directory, and run the following command "if" your project is not initialized as a git repository: - - ```bash - $ git init - ``` - -- Add Alamofire as a git [submodule](https://git-scm.com/docs/git-submodule) by running the following command: - - ```bash - $ git submodule add https://github.com/Alamofire/Alamofire.git - ``` - -- Open the new `Alamofire` folder, and drag the `Alamofire.xcodeproj` into the Project Navigator of your application's Xcode project. - - > It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter. - -- Select the `Alamofire.xcodeproj` in the Project Navigator and verify the deployment target matches that of your application target. -- Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar. -- In the tab bar at the top of that window, open the "General" panel. -- Click on the `+` button under the "Embedded Binaries" section. -- You will see two different `Alamofire.xcodeproj` folders each with two different versions of the `Alamofire.framework` nested inside a `Products` folder. - - > It does not matter which `Products` folder you choose from, but it does matter whether you choose the top or bottom `Alamofire.framework`. - -- Select the top `Alamofire.framework` for iOS and the bottom one for OS X. - - > You can verify which one you selected by inspecting the build log for your project. The build target for `Alamofire` will be listed as either `Alamofire iOS`, `Alamofire macOS`, `Alamofire tvOS` or `Alamofire watchOS`. - -- And that's it! - - > The `Alamofire.framework` is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device. - -## Open Radars - -The following radars have some effect on the current implementation of Alamofire. - -- [`rdar://21349340`](http://www.openradar.me/radar?id=5517037090635776) - Compiler throwing warning due to toll-free bridging issue in test case -- `rdar://26870455` - Background URL Session Configurations do not work in the simulator -- `rdar://26849668` - Some URLProtocol APIs do not properly handle `URLRequest` -- [`rdar://36082113`](http://openradar.appspot.com/radar?id=4942308441063424) - `URLSessionTaskMetrics` failing to link on watchOS 3.0+ - -## Resolved Radars - -The following radars have been resolved over time after being filed against the Alamofire project. - -- [`rdar://26761490`](http://www.openradar.me/radar?id=5010235949318144) - Swift string interpolation causing memory leak with common usage (Resolved on 9/1/17 in Xcode 9 beta 6). - -## FAQ - -### What's the origin of the name Alamofire? - -Alamofire is named after the [Alamo Fire flower](https://aggie-horticulture.tamu.edu/wildseed/alamofire.html), a hybrid variant of the Bluebonnet, the official state flower of Texas. - -### What logic belongs in a Router vs. a Request Adapter? - -Simple, static data such as paths, parameters and common headers belong in the `Router`. Dynamic data such as an `Authorization` header whose value can changed based on an authentication system belongs in a `RequestAdapter`. - -The reason the dynamic data MUST be placed into the `RequestAdapter` is to support retry operations. When a `Request` is retried, the original request is not rebuilt meaning the `Router` will not be called again. The `RequestAdapter` is called again allowing the dynamic data to be updated on the original request before retrying the `Request`. - -## Credits - -Alamofire is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org). You can follow them on Twitter at [@AlamofireSF](https://twitter.com/AlamofireSF) for project updates and releases. - -### Security Disclosure - -If you believe you have identified a security vulnerability with Alamofire, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker. - -## Donations - -The [ASF](https://github.com/Alamofire/Foundation#members) is looking to raise money to officially stay registered as a federal non-profit organization. -Registering will allow us members to gain some legal protections and also allow us to put donations to use, tax free. -Donating to the ASF will enable us to: - -- Pay our yearly legal fees to keep the non-profit in good status -- Pay for our mail servers to help us stay on top of all questions and security issues -- Potentially fund test servers to make it easier for us to test the edge cases -- Potentially fund developers to work on one of our projects full-time - -The community adoption of the ASF libraries has been amazing. -We are greatly humbled by your enthusiasm around the projects, and want to continue to do everything we can to move the needle forward. -With your continued support, the ASF will be able to improve its reach and also provide better legal safety for the core members. -If you use any of our libraries for work, see if your employers would be interested in donating. -Any amount you can donate today to help us reach our goal would be greatly appreciated. - -[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W34WPEE74APJQ) - -## License - -Alamofire is released under the MIT license. [See LICENSE](https://github.com/Alamofire/Alamofire/blob/master/LICENSE) for details. diff --git a/Example/Pods/Alamofire/Source/AFError.swift b/Example/Pods/Alamofire/Source/AFError.swift deleted file mode 100644 index b163f60..0000000 --- a/Example/Pods/Alamofire/Source/AFError.swift +++ /dev/null @@ -1,460 +0,0 @@ -// -// AFError.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// `AFError` is the error type returned by Alamofire. It encompasses a few different types of errors, each with -/// their own associated reasons. -/// -/// - invalidURL: Returned when a `URLConvertible` type fails to create a valid `URL`. -/// - parameterEncodingFailed: Returned when a parameter encoding object throws an error during the encoding process. -/// - multipartEncodingFailed: Returned when some step in the multipart encoding process fails. -/// - responseValidationFailed: Returned when a `validate()` call fails. -/// - responseSerializationFailed: Returned when a response serializer encounters an error in the serialization process. -public enum AFError: Error { - /// The underlying reason the parameter encoding error occurred. - /// - /// - missingURL: The URL request did not have a URL to encode. - /// - jsonEncodingFailed: JSON serialization failed with an underlying system error during the - /// encoding process. - /// - propertyListEncodingFailed: Property list serialization failed with an underlying system error during - /// encoding process. - public enum ParameterEncodingFailureReason { - case missingURL - case jsonEncodingFailed(error: Error) - case propertyListEncodingFailed(error: Error) - } - - /// The underlying reason the multipart encoding error occurred. - /// - /// - bodyPartURLInvalid: The `fileURL` provided for reading an encodable body part isn't a - /// file URL. - /// - bodyPartFilenameInvalid: The filename of the `fileURL` provided has either an empty - /// `lastPathComponent` or `pathExtension. - /// - bodyPartFileNotReachable: The file at the `fileURL` provided was not reachable. - /// - bodyPartFileNotReachableWithError: Attempting to check the reachability of the `fileURL` provided threw - /// an error. - /// - bodyPartFileIsDirectory: The file at the `fileURL` provided is actually a directory. - /// - bodyPartFileSizeNotAvailable: The size of the file at the `fileURL` provided was not returned by - /// the system. - /// - bodyPartFileSizeQueryFailedWithError: The attempt to find the size of the file at the `fileURL` provided - /// threw an error. - /// - bodyPartInputStreamCreationFailed: An `InputStream` could not be created for the provided `fileURL`. - /// - outputStreamCreationFailed: An `OutputStream` could not be created when attempting to write the - /// encoded data to disk. - /// - outputStreamFileAlreadyExists: The encoded body data could not be writtent disk because a file - /// already exists at the provided `fileURL`. - /// - outputStreamURLInvalid: The `fileURL` provided for writing the encoded body data to disk is - /// not a file URL. - /// - outputStreamWriteFailed: The attempt to write the encoded body data to disk failed with an - /// underlying error. - /// - inputStreamReadFailed: The attempt to read an encoded body part `InputStream` failed with - /// underlying system error. - public enum MultipartEncodingFailureReason { - case bodyPartURLInvalid(url: URL) - case bodyPartFilenameInvalid(in: URL) - case bodyPartFileNotReachable(at: URL) - case bodyPartFileNotReachableWithError(atURL: URL, error: Error) - case bodyPartFileIsDirectory(at: URL) - case bodyPartFileSizeNotAvailable(at: URL) - case bodyPartFileSizeQueryFailedWithError(forURL: URL, error: Error) - case bodyPartInputStreamCreationFailed(for: URL) - - case outputStreamCreationFailed(for: URL) - case outputStreamFileAlreadyExists(at: URL) - case outputStreamURLInvalid(url: URL) - case outputStreamWriteFailed(error: Error) - - case inputStreamReadFailed(error: Error) - } - - /// The underlying reason the response validation error occurred. - /// - /// - dataFileNil: The data file containing the server response did not exist. - /// - dataFileReadFailed: The data file containing the server response could not be read. - /// - missingContentType: The response did not contain a `Content-Type` and the `acceptableContentTypes` - /// provided did not contain wildcard type. - /// - unacceptableContentType: The response `Content-Type` did not match any type in the provided - /// `acceptableContentTypes`. - /// - unacceptableStatusCode: The response status code was not acceptable. - public enum ResponseValidationFailureReason { - case dataFileNil - case dataFileReadFailed(at: URL) - case missingContentType(acceptableContentTypes: [String]) - case unacceptableContentType(acceptableContentTypes: [String], responseContentType: String) - case unacceptableStatusCode(code: Int) - } - - /// The underlying reason the response serialization error occurred. - /// - /// - inputDataNil: The server response contained no data. - /// - inputDataNilOrZeroLength: The server response contained no data or the data was zero length. - /// - inputFileNil: The file containing the server response did not exist. - /// - inputFileReadFailed: The file containing the server response could not be read. - /// - stringSerializationFailed: String serialization failed using the provided `String.Encoding`. - /// - jsonSerializationFailed: JSON serialization failed with an underlying system error. - /// - propertyListSerializationFailed: Property list serialization failed with an underlying system error. - public enum ResponseSerializationFailureReason { - case inputDataNil - case inputDataNilOrZeroLength - case inputFileNil - case inputFileReadFailed(at: URL) - case stringSerializationFailed(encoding: String.Encoding) - case jsonSerializationFailed(error: Error) - case propertyListSerializationFailed(error: Error) - } - - case invalidURL(url: URLConvertible) - case parameterEncodingFailed(reason: ParameterEncodingFailureReason) - case multipartEncodingFailed(reason: MultipartEncodingFailureReason) - case responseValidationFailed(reason: ResponseValidationFailureReason) - case responseSerializationFailed(reason: ResponseSerializationFailureReason) -} - -// MARK: - Adapt Error - -struct AdaptError: Error { - let error: Error -} - -extension Error { - var underlyingAdaptError: Error? { return (self as? AdaptError)?.error } -} - -// MARK: - Error Booleans - -extension AFError { - /// Returns whether the AFError is an invalid URL error. - public var isInvalidURLError: Bool { - if case .invalidURL = self { return true } - return false - } - - /// Returns whether the AFError is a parameter encoding error. When `true`, the `underlyingError` property will - /// contain the associated value. - public var isParameterEncodingError: Bool { - if case .parameterEncodingFailed = self { return true } - return false - } - - /// Returns whether the AFError is a multipart encoding error. When `true`, the `url` and `underlyingError` properties - /// will contain the associated values. - public var isMultipartEncodingError: Bool { - if case .multipartEncodingFailed = self { return true } - return false - } - - /// Returns whether the `AFError` is a response validation error. When `true`, the `acceptableContentTypes`, - /// `responseContentType`, and `responseCode` properties will contain the associated values. - public var isResponseValidationError: Bool { - if case .responseValidationFailed = self { return true } - return false - } - - /// Returns whether the `AFError` is a response serialization error. When `true`, the `failedStringEncoding` and - /// `underlyingError` properties will contain the associated values. - public var isResponseSerializationError: Bool { - if case .responseSerializationFailed = self { return true } - return false - } -} - -// MARK: - Convenience Properties - -extension AFError { - /// The `URLConvertible` associated with the error. - public var urlConvertible: URLConvertible? { - switch self { - case .invalidURL(let url): - return url - default: - return nil - } - } - - /// The `URL` associated with the error. - public var url: URL? { - switch self { - case .multipartEncodingFailed(let reason): - return reason.url - default: - return nil - } - } - - /// The `Error` returned by a system framework associated with a `.parameterEncodingFailed`, - /// `.multipartEncodingFailed` or `.responseSerializationFailed` error. - public var underlyingError: Error? { - switch self { - case .parameterEncodingFailed(let reason): - return reason.underlyingError - case .multipartEncodingFailed(let reason): - return reason.underlyingError - case .responseSerializationFailed(let reason): - return reason.underlyingError - default: - return nil - } - } - - /// The acceptable `Content-Type`s of a `.responseValidationFailed` error. - public var acceptableContentTypes: [String]? { - switch self { - case .responseValidationFailed(let reason): - return reason.acceptableContentTypes - default: - return nil - } - } - - /// The response `Content-Type` of a `.responseValidationFailed` error. - public var responseContentType: String? { - switch self { - case .responseValidationFailed(let reason): - return reason.responseContentType - default: - return nil - } - } - - /// The response code of a `.responseValidationFailed` error. - public var responseCode: Int? { - switch self { - case .responseValidationFailed(let reason): - return reason.responseCode - default: - return nil - } - } - - /// The `String.Encoding` associated with a failed `.stringResponse()` call. - public var failedStringEncoding: String.Encoding? { - switch self { - case .responseSerializationFailed(let reason): - return reason.failedStringEncoding - default: - return nil - } - } -} - -extension AFError.ParameterEncodingFailureReason { - var underlyingError: Error? { - switch self { - case .jsonEncodingFailed(let error), .propertyListEncodingFailed(let error): - return error - default: - return nil - } - } -} - -extension AFError.MultipartEncodingFailureReason { - var url: URL? { - switch self { - case .bodyPartURLInvalid(let url), .bodyPartFilenameInvalid(let url), .bodyPartFileNotReachable(let url), - .bodyPartFileIsDirectory(let url), .bodyPartFileSizeNotAvailable(let url), - .bodyPartInputStreamCreationFailed(let url), .outputStreamCreationFailed(let url), - .outputStreamFileAlreadyExists(let url), .outputStreamURLInvalid(let url), - .bodyPartFileNotReachableWithError(let url, _), .bodyPartFileSizeQueryFailedWithError(let url, _): - return url - default: - return nil - } - } - - var underlyingError: Error? { - switch self { - case .bodyPartFileNotReachableWithError(_, let error), .bodyPartFileSizeQueryFailedWithError(_, let error), - .outputStreamWriteFailed(let error), .inputStreamReadFailed(let error): - return error - default: - return nil - } - } -} - -extension AFError.ResponseValidationFailureReason { - var acceptableContentTypes: [String]? { - switch self { - case .missingContentType(let types), .unacceptableContentType(let types, _): - return types - default: - return nil - } - } - - var responseContentType: String? { - switch self { - case .unacceptableContentType(_, let responseType): - return responseType - default: - return nil - } - } - - var responseCode: Int? { - switch self { - case .unacceptableStatusCode(let code): - return code - default: - return nil - } - } -} - -extension AFError.ResponseSerializationFailureReason { - var failedStringEncoding: String.Encoding? { - switch self { - case .stringSerializationFailed(let encoding): - return encoding - default: - return nil - } - } - - var underlyingError: Error? { - switch self { - case .jsonSerializationFailed(let error), .propertyListSerializationFailed(let error): - return error - default: - return nil - } - } -} - -// MARK: - Error Descriptions - -extension AFError: LocalizedError { - public var errorDescription: String? { - switch self { - case .invalidURL(let url): - return "URL is not valid: \(url)" - case .parameterEncodingFailed(let reason): - return reason.localizedDescription - case .multipartEncodingFailed(let reason): - return reason.localizedDescription - case .responseValidationFailed(let reason): - return reason.localizedDescription - case .responseSerializationFailed(let reason): - return reason.localizedDescription - } - } -} - -extension AFError.ParameterEncodingFailureReason { - var localizedDescription: String { - switch self { - case .missingURL: - return "URL request to encode was missing a URL" - case .jsonEncodingFailed(let error): - return "JSON could not be encoded because of error:\n\(error.localizedDescription)" - case .propertyListEncodingFailed(let error): - return "PropertyList could not be encoded because of error:\n\(error.localizedDescription)" - } - } -} - -extension AFError.MultipartEncodingFailureReason { - var localizedDescription: String { - switch self { - case .bodyPartURLInvalid(let url): - return "The URL provided is not a file URL: \(url)" - case .bodyPartFilenameInvalid(let url): - return "The URL provided does not have a valid filename: \(url)" - case .bodyPartFileNotReachable(let url): - return "The URL provided is not reachable: \(url)" - case .bodyPartFileNotReachableWithError(let url, let error): - return ( - "The system returned an error while checking the provided URL for " + - "reachability.\nURL: \(url)\nError: \(error)" - ) - case .bodyPartFileIsDirectory(let url): - return "The URL provided is a directory: \(url)" - case .bodyPartFileSizeNotAvailable(let url): - return "Could not fetch the file size from the provided URL: \(url)" - case .bodyPartFileSizeQueryFailedWithError(let url, let error): - return ( - "The system returned an error while attempting to fetch the file size from the " + - "provided URL.\nURL: \(url)\nError: \(error)" - ) - case .bodyPartInputStreamCreationFailed(let url): - return "Failed to create an InputStream for the provided URL: \(url)" - case .outputStreamCreationFailed(let url): - return "Failed to create an OutputStream for URL: \(url)" - case .outputStreamFileAlreadyExists(let url): - return "A file already exists at the provided URL: \(url)" - case .outputStreamURLInvalid(let url): - return "The provided OutputStream URL is invalid: \(url)" - case .outputStreamWriteFailed(let error): - return "OutputStream write failed with error: \(error)" - case .inputStreamReadFailed(let error): - return "InputStream read failed with error: \(error)" - } - } -} - -extension AFError.ResponseSerializationFailureReason { - var localizedDescription: String { - switch self { - case .inputDataNil: - return "Response could not be serialized, input data was nil." - case .inputDataNilOrZeroLength: - return "Response could not be serialized, input data was nil or zero length." - case .inputFileNil: - return "Response could not be serialized, input file was nil." - case .inputFileReadFailed(let url): - return "Response could not be serialized, input file could not be read: \(url)." - case .stringSerializationFailed(let encoding): - return "String could not be serialized with encoding: \(encoding)." - case .jsonSerializationFailed(let error): - return "JSON could not be serialized because of error:\n\(error.localizedDescription)" - case .propertyListSerializationFailed(let error): - return "PropertyList could not be serialized because of error:\n\(error.localizedDescription)" - } - } -} - -extension AFError.ResponseValidationFailureReason { - var localizedDescription: String { - switch self { - case .dataFileNil: - return "Response could not be validated, data file was nil." - case .dataFileReadFailed(let url): - return "Response could not be validated, data file could not be read: \(url)." - case .missingContentType(let types): - return ( - "Response Content-Type was missing and acceptable content types " + - "(\(types.joined(separator: ","))) do not match \"*/*\"." - ) - case .unacceptableContentType(let acceptableTypes, let responseType): - return ( - "Response Content-Type \"\(responseType)\" does not match any acceptable types: " + - "\(acceptableTypes.joined(separator: ","))." - ) - case .unacceptableStatusCode(let code): - return "Response status code was unacceptable: \(code)." - } - } -} diff --git a/Example/Pods/Alamofire/Source/Alamofire.swift b/Example/Pods/Alamofire/Source/Alamofire.swift deleted file mode 100644 index 20c3672..0000000 --- a/Example/Pods/Alamofire/Source/Alamofire.swift +++ /dev/null @@ -1,465 +0,0 @@ -// -// Alamofire.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// Types adopting the `URLConvertible` protocol can be used to construct URLs, which are then used to construct -/// URL requests. -public protocol URLConvertible { - /// Returns a URL that conforms to RFC 2396 or throws an `Error`. - /// - /// - throws: An `Error` if the type cannot be converted to a `URL`. - /// - /// - returns: A URL or throws an `Error`. - func asURL() throws -> URL -} - -extension String: URLConvertible { - /// Returns a URL if `self` represents a valid URL string that conforms to RFC 2396 or throws an `AFError`. - /// - /// - throws: An `AFError.invalidURL` if `self` is not a valid URL string. - /// - /// - returns: A URL or throws an `AFError`. - public func asURL() throws -> URL { - guard let url = URL(string: self) else { throw AFError.invalidURL(url: self) } - return url - } -} - -extension URL: URLConvertible { - /// Returns self. - public func asURL() throws -> URL { return self } -} - -extension URLComponents: URLConvertible { - /// Returns a URL if `url` is not nil, otherwise throws an `Error`. - /// - /// - throws: An `AFError.invalidURL` if `url` is `nil`. - /// - /// - returns: A URL or throws an `AFError`. - public func asURL() throws -> URL { - guard let url = url else { throw AFError.invalidURL(url: self) } - return url - } -} - -// MARK: - - -/// Types adopting the `URLRequestConvertible` protocol can be used to construct URL requests. -public protocol URLRequestConvertible { - /// Returns a URL request or throws if an `Error` was encountered. - /// - /// - throws: An `Error` if the underlying `URLRequest` is `nil`. - /// - /// - returns: A URL request. - func asURLRequest() throws -> URLRequest -} - -extension URLRequestConvertible { - /// The URL request. - public var urlRequest: URLRequest? { return try? asURLRequest() } -} - -extension URLRequest: URLRequestConvertible { - /// Returns a URL request or throws if an `Error` was encountered. - public func asURLRequest() throws -> URLRequest { return self } -} - -// MARK: - - -extension URLRequest { - /// Creates an instance with the specified `method`, `urlString` and `headers`. - /// - /// - parameter url: The URL. - /// - parameter method: The HTTP method. - /// - parameter headers: The HTTP headers. `nil` by default. - /// - /// - returns: The new `URLRequest` instance. - public init(url: URLConvertible, method: HTTPMethod, headers: HTTPHeaders? = nil) throws { - let url = try url.asURL() - - self.init(url: url) - - httpMethod = method.rawValue - - if let headers = headers { - for (headerField, headerValue) in headers { - setValue(headerValue, forHTTPHeaderField: headerField) - } - } - } - - func adapt(using adapter: RequestAdapter?) throws -> URLRequest { - guard let adapter = adapter else { return self } - return try adapter.adapt(self) - } -} - -// MARK: - Data Request - -/// Creates a `DataRequest` using the default `SessionManager` to retrieve the contents of the specified `url`, -/// `method`, `parameters`, `encoding` and `headers`. -/// -/// - parameter url: The URL. -/// - parameter method: The HTTP method. `.get` by default. -/// - parameter parameters: The parameters. `nil` by default. -/// - parameter encoding: The parameter encoding. `URLEncoding.default` by default. -/// - parameter headers: The HTTP headers. `nil` by default. -/// -/// - returns: The created `DataRequest`. -@discardableResult -public func request( - _ url: URLConvertible, - method: HTTPMethod = .get, - parameters: Parameters? = nil, - encoding: ParameterEncoding = URLEncoding.default, - headers: HTTPHeaders? = nil) - -> DataRequest -{ - return SessionManager.default.request( - url, - method: method, - parameters: parameters, - encoding: encoding, - headers: headers - ) -} - -/// Creates a `DataRequest` using the default `SessionManager` to retrieve the contents of a URL based on the -/// specified `urlRequest`. -/// -/// - parameter urlRequest: The URL request -/// -/// - returns: The created `DataRequest`. -@discardableResult -public func request(_ urlRequest: URLRequestConvertible) -> DataRequest { - return SessionManager.default.request(urlRequest) -} - -// MARK: - Download Request - -// MARK: URL Request - -/// Creates a `DownloadRequest` using the default `SessionManager` to retrieve the contents of the specified `url`, -/// `method`, `parameters`, `encoding`, `headers` and save them to the `destination`. -/// -/// If `destination` is not specified, the contents will remain in the temporary location determined by the -/// underlying URL session. -/// -/// - parameter url: The URL. -/// - parameter method: The HTTP method. `.get` by default. -/// - parameter parameters: The parameters. `nil` by default. -/// - parameter encoding: The parameter encoding. `URLEncoding.default` by default. -/// - parameter headers: The HTTP headers. `nil` by default. -/// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. -/// -/// - returns: The created `DownloadRequest`. -@discardableResult -public func download( - _ url: URLConvertible, - method: HTTPMethod = .get, - parameters: Parameters? = nil, - encoding: ParameterEncoding = URLEncoding.default, - headers: HTTPHeaders? = nil, - to destination: DownloadRequest.DownloadFileDestination? = nil) - -> DownloadRequest -{ - return SessionManager.default.download( - url, - method: method, - parameters: parameters, - encoding: encoding, - headers: headers, - to: destination - ) -} - -/// Creates a `DownloadRequest` using the default `SessionManager` to retrieve the contents of a URL based on the -/// specified `urlRequest` and save them to the `destination`. -/// -/// If `destination` is not specified, the contents will remain in the temporary location determined by the -/// underlying URL session. -/// -/// - parameter urlRequest: The URL request. -/// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. -/// -/// - returns: The created `DownloadRequest`. -@discardableResult -public func download( - _ urlRequest: URLRequestConvertible, - to destination: DownloadRequest.DownloadFileDestination? = nil) - -> DownloadRequest -{ - return SessionManager.default.download(urlRequest, to: destination) -} - -// MARK: Resume Data - -/// Creates a `DownloadRequest` using the default `SessionManager` from the `resumeData` produced from a -/// previous request cancellation to retrieve the contents of the original request and save them to the `destination`. -/// -/// If `destination` is not specified, the contents will remain in the temporary location determined by the -/// underlying URL session. -/// -/// On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken -/// on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the -/// data is written incorrectly and will always fail to resume the download. For more information about the bug and -/// possible workarounds, please refer to the following Stack Overflow post: -/// -/// - http://stackoverflow.com/a/39347461/1342462 -/// -/// - parameter resumeData: The resume data. This is an opaque data blob produced by `URLSessionDownloadTask` -/// when a task is cancelled. See `URLSession -downloadTask(withResumeData:)` for additional -/// information. -/// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. -/// -/// - returns: The created `DownloadRequest`. -@discardableResult -public func download( - resumingWith resumeData: Data, - to destination: DownloadRequest.DownloadFileDestination? = nil) - -> DownloadRequest -{ - return SessionManager.default.download(resumingWith: resumeData, to: destination) -} - -// MARK: - Upload Request - -// MARK: File - -/// Creates an `UploadRequest` using the default `SessionManager` from the specified `url`, `method` and `headers` -/// for uploading the `file`. -/// -/// - parameter file: The file to upload. -/// - parameter url: The URL. -/// - parameter method: The HTTP method. `.post` by default. -/// - parameter headers: The HTTP headers. `nil` by default. -/// -/// - returns: The created `UploadRequest`. -@discardableResult -public func upload( - _ fileURL: URL, - to url: URLConvertible, - method: HTTPMethod = .post, - headers: HTTPHeaders? = nil) - -> UploadRequest -{ - return SessionManager.default.upload(fileURL, to: url, method: method, headers: headers) -} - -/// Creates a `UploadRequest` using the default `SessionManager` from the specified `urlRequest` for -/// uploading the `file`. -/// -/// - parameter file: The file to upload. -/// - parameter urlRequest: The URL request. -/// -/// - returns: The created `UploadRequest`. -@discardableResult -public func upload(_ fileURL: URL, with urlRequest: URLRequestConvertible) -> UploadRequest { - return SessionManager.default.upload(fileURL, with: urlRequest) -} - -// MARK: Data - -/// Creates an `UploadRequest` using the default `SessionManager` from the specified `url`, `method` and `headers` -/// for uploading the `data`. -/// -/// - parameter data: The data to upload. -/// - parameter url: The URL. -/// - parameter method: The HTTP method. `.post` by default. -/// - parameter headers: The HTTP headers. `nil` by default. -/// -/// - returns: The created `UploadRequest`. -@discardableResult -public func upload( - _ data: Data, - to url: URLConvertible, - method: HTTPMethod = .post, - headers: HTTPHeaders? = nil) - -> UploadRequest -{ - return SessionManager.default.upload(data, to: url, method: method, headers: headers) -} - -/// Creates an `UploadRequest` using the default `SessionManager` from the specified `urlRequest` for -/// uploading the `data`. -/// -/// - parameter data: The data to upload. -/// - parameter urlRequest: The URL request. -/// -/// - returns: The created `UploadRequest`. -@discardableResult -public func upload(_ data: Data, with urlRequest: URLRequestConvertible) -> UploadRequest { - return SessionManager.default.upload(data, with: urlRequest) -} - -// MARK: InputStream - -/// Creates an `UploadRequest` using the default `SessionManager` from the specified `url`, `method` and `headers` -/// for uploading the `stream`. -/// -/// - parameter stream: The stream to upload. -/// - parameter url: The URL. -/// - parameter method: The HTTP method. `.post` by default. -/// - parameter headers: The HTTP headers. `nil` by default. -/// -/// - returns: The created `UploadRequest`. -@discardableResult -public func upload( - _ stream: InputStream, - to url: URLConvertible, - method: HTTPMethod = .post, - headers: HTTPHeaders? = nil) - -> UploadRequest -{ - return SessionManager.default.upload(stream, to: url, method: method, headers: headers) -} - -/// Creates an `UploadRequest` using the default `SessionManager` from the specified `urlRequest` for -/// uploading the `stream`. -/// -/// - parameter urlRequest: The URL request. -/// - parameter stream: The stream to upload. -/// -/// - returns: The created `UploadRequest`. -@discardableResult -public func upload(_ stream: InputStream, with urlRequest: URLRequestConvertible) -> UploadRequest { - return SessionManager.default.upload(stream, with: urlRequest) -} - -// MARK: MultipartFormData - -/// Encodes `multipartFormData` using `encodingMemoryThreshold` with the default `SessionManager` and calls -/// `encodingCompletion` with new `UploadRequest` using the `url`, `method` and `headers`. -/// -/// It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative -/// payload is small, encoding the data in-memory and directly uploading to a server is the by far the most -/// efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to -/// be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory -/// footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be -/// used for larger payloads such as video content. -/// -/// The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory -/// or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, -/// encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk -/// during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding -/// technique was used. -/// -/// - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. -/// - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. -/// `multipartFormDataEncodingMemoryThreshold` by default. -/// - parameter url: The URL. -/// - parameter method: The HTTP method. `.post` by default. -/// - parameter headers: The HTTP headers. `nil` by default. -/// - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. -public func upload( - multipartFormData: @escaping (MultipartFormData) -> Void, - usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, - to url: URLConvertible, - method: HTTPMethod = .post, - headers: HTTPHeaders? = nil, - encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?) -{ - return SessionManager.default.upload( - multipartFormData: multipartFormData, - usingThreshold: encodingMemoryThreshold, - to: url, - method: method, - headers: headers, - encodingCompletion: encodingCompletion - ) -} - -/// Encodes `multipartFormData` using `encodingMemoryThreshold` and the default `SessionManager` and -/// calls `encodingCompletion` with new `UploadRequest` using the `urlRequest`. -/// -/// It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative -/// payload is small, encoding the data in-memory and directly uploading to a server is the by far the most -/// efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to -/// be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory -/// footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be -/// used for larger payloads such as video content. -/// -/// The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory -/// or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, -/// encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk -/// during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding -/// technique was used. -/// -/// - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. -/// - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. -/// `multipartFormDataEncodingMemoryThreshold` by default. -/// - parameter urlRequest: The URL request. -/// - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. -public func upload( - multipartFormData: @escaping (MultipartFormData) -> Void, - usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, - with urlRequest: URLRequestConvertible, - encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?) -{ - return SessionManager.default.upload( - multipartFormData: multipartFormData, - usingThreshold: encodingMemoryThreshold, - with: urlRequest, - encodingCompletion: encodingCompletion - ) -} - -#if !os(watchOS) - -// MARK: - Stream Request - -// MARK: Hostname and Port - -/// Creates a `StreamRequest` using the default `SessionManager` for bidirectional streaming with the `hostname` -/// and `port`. -/// -/// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. -/// -/// - parameter hostName: The hostname of the server to connect to. -/// - parameter port: The port of the server to connect to. -/// -/// - returns: The created `StreamRequest`. -@discardableResult -@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) -public func stream(withHostName hostName: String, port: Int) -> StreamRequest { - return SessionManager.default.stream(withHostName: hostName, port: port) -} - -// MARK: NetService - -/// Creates a `StreamRequest` using the default `SessionManager` for bidirectional streaming with the `netService`. -/// -/// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. -/// -/// - parameter netService: The net service used to identify the endpoint. -/// -/// - returns: The created `StreamRequest`. -@discardableResult -@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) -public func stream(with netService: NetService) -> StreamRequest { - return SessionManager.default.stream(with: netService) -} - -#endif diff --git a/Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift b/Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift deleted file mode 100644 index a54673c..0000000 --- a/Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// DispatchQueue+Alamofire.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Dispatch -import Foundation - -extension DispatchQueue { - static var userInteractive: DispatchQueue { return DispatchQueue.global(qos: .userInteractive) } - static var userInitiated: DispatchQueue { return DispatchQueue.global(qos: .userInitiated) } - static var utility: DispatchQueue { return DispatchQueue.global(qos: .utility) } - static var background: DispatchQueue { return DispatchQueue.global(qos: .background) } - - func after(_ delay: TimeInterval, execute closure: @escaping () -> Void) { - asyncAfter(deadline: .now() + delay, execute: closure) - } -} diff --git a/Example/Pods/Alamofire/Source/MultipartFormData.swift b/Example/Pods/Alamofire/Source/MultipartFormData.swift deleted file mode 100644 index b840138..0000000 --- a/Example/Pods/Alamofire/Source/MultipartFormData.swift +++ /dev/null @@ -1,580 +0,0 @@ -// -// MultipartFormData.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -#if os(iOS) || os(watchOS) || os(tvOS) -import MobileCoreServices -#elseif os(macOS) -import CoreServices -#endif - -/// Constructs `multipart/form-data` for uploads within an HTTP or HTTPS body. There are currently two ways to encode -/// multipart form data. The first way is to encode the data directly in memory. This is very efficient, but can lead -/// to memory issues if the dataset is too large. The second way is designed for larger datasets and will write all the -/// data to a single file on disk with all the proper boundary segmentation. The second approach MUST be used for -/// larger datasets such as video content, otherwise your app may run out of memory when trying to encode the dataset. -/// -/// For more information on `multipart/form-data` in general, please refer to the RFC-2388 and RFC-2045 specs as well -/// and the w3 form documentation. -/// -/// - https://www.ietf.org/rfc/rfc2388.txt -/// - https://www.ietf.org/rfc/rfc2045.txt -/// - https://www.w3.org/TR/html401/interact/forms.html#h-17.13 -open class MultipartFormData { - - // MARK: - Helper Types - - struct EncodingCharacters { - static let crlf = "\r\n" - } - - struct BoundaryGenerator { - enum BoundaryType { - case initial, encapsulated, final - } - - static func randomBoundary() -> String { - return String(format: "alamofire.boundary.%08x%08x", arc4random(), arc4random()) - } - - static func boundaryData(forBoundaryType boundaryType: BoundaryType, boundary: String) -> Data { - let boundaryText: String - - switch boundaryType { - case .initial: - boundaryText = "--\(boundary)\(EncodingCharacters.crlf)" - case .encapsulated: - boundaryText = "\(EncodingCharacters.crlf)--\(boundary)\(EncodingCharacters.crlf)" - case .final: - boundaryText = "\(EncodingCharacters.crlf)--\(boundary)--\(EncodingCharacters.crlf)" - } - - return boundaryText.data(using: String.Encoding.utf8, allowLossyConversion: false)! - } - } - - class BodyPart { - let headers: HTTPHeaders - let bodyStream: InputStream - let bodyContentLength: UInt64 - var hasInitialBoundary = false - var hasFinalBoundary = false - - init(headers: HTTPHeaders, bodyStream: InputStream, bodyContentLength: UInt64) { - self.headers = headers - self.bodyStream = bodyStream - self.bodyContentLength = bodyContentLength - } - } - - // MARK: - Properties - - /// The `Content-Type` header value containing the boundary used to generate the `multipart/form-data`. - open lazy var contentType: String = "multipart/form-data; boundary=\(self.boundary)" - - /// The content length of all body parts used to generate the `multipart/form-data` not including the boundaries. - public var contentLength: UInt64 { return bodyParts.reduce(0) { $0 + $1.bodyContentLength } } - - /// The boundary used to separate the body parts in the encoded form data. - public var boundary: String - - private var bodyParts: [BodyPart] - private var bodyPartError: AFError? - private let streamBufferSize: Int - - // MARK: - Lifecycle - - /// Creates a multipart form data object. - /// - /// - returns: The multipart form data object. - public init() { - self.boundary = BoundaryGenerator.randomBoundary() - self.bodyParts = [] - - /// - /// The optimal read/write buffer size in bytes for input and output streams is 1024 (1KB). For more - /// information, please refer to the following article: - /// - https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Streams/Articles/ReadingInputStreams.html - /// - - self.streamBufferSize = 1024 - } - - // MARK: - Body Parts - - /// Creates a body part from the data and appends it to the multipart form data object. - /// - /// The body part data will be encoded using the following format: - /// - /// - `Content-Disposition: form-data; name=#{name}` (HTTP Header) - /// - Encoded data - /// - Multipart form boundary - /// - /// - parameter data: The data to encode into the multipart form data. - /// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. - public func append(_ data: Data, withName name: String) { - let headers = contentHeaders(withName: name) - let stream = InputStream(data: data) - let length = UInt64(data.count) - - append(stream, withLength: length, headers: headers) - } - - /// Creates a body part from the data and appends it to the multipart form data object. - /// - /// The body part data will be encoded using the following format: - /// - /// - `Content-Disposition: form-data; name=#{name}` (HTTP Header) - /// - `Content-Type: #{generated mimeType}` (HTTP Header) - /// - Encoded data - /// - Multipart form boundary - /// - /// - parameter data: The data to encode into the multipart form data. - /// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. - /// - parameter mimeType: The MIME type to associate with the data content type in the `Content-Type` HTTP header. - public func append(_ data: Data, withName name: String, mimeType: String) { - let headers = contentHeaders(withName: name, mimeType: mimeType) - let stream = InputStream(data: data) - let length = UInt64(data.count) - - append(stream, withLength: length, headers: headers) - } - - /// Creates a body part from the data and appends it to the multipart form data object. - /// - /// The body part data will be encoded using the following format: - /// - /// - `Content-Disposition: form-data; name=#{name}; filename=#{filename}` (HTTP Header) - /// - `Content-Type: #{mimeType}` (HTTP Header) - /// - Encoded file data - /// - Multipart form boundary - /// - /// - parameter data: The data to encode into the multipart form data. - /// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. - /// - parameter fileName: The filename to associate with the data in the `Content-Disposition` HTTP header. - /// - parameter mimeType: The MIME type to associate with the data in the `Content-Type` HTTP header. - public func append(_ data: Data, withName name: String, fileName: String, mimeType: String) { - let headers = contentHeaders(withName: name, fileName: fileName, mimeType: mimeType) - let stream = InputStream(data: data) - let length = UInt64(data.count) - - append(stream, withLength: length, headers: headers) - } - - /// Creates a body part from the file and appends it to the multipart form data object. - /// - /// The body part data will be encoded using the following format: - /// - /// - `Content-Disposition: form-data; name=#{name}; filename=#{generated filename}` (HTTP Header) - /// - `Content-Type: #{generated mimeType}` (HTTP Header) - /// - Encoded file data - /// - Multipart form boundary - /// - /// The filename in the `Content-Disposition` HTTP header is generated from the last path component of the - /// `fileURL`. The `Content-Type` HTTP header MIME type is generated by mapping the `fileURL` extension to the - /// system associated MIME type. - /// - /// - parameter fileURL: The URL of the file whose content will be encoded into the multipart form data. - /// - parameter name: The name to associate with the file content in the `Content-Disposition` HTTP header. - public func append(_ fileURL: URL, withName name: String) { - let fileName = fileURL.lastPathComponent - let pathExtension = fileURL.pathExtension - - if !fileName.isEmpty && !pathExtension.isEmpty { - let mime = mimeType(forPathExtension: pathExtension) - append(fileURL, withName: name, fileName: fileName, mimeType: mime) - } else { - setBodyPartError(withReason: .bodyPartFilenameInvalid(in: fileURL)) - } - } - - /// Creates a body part from the file and appends it to the multipart form data object. - /// - /// The body part data will be encoded using the following format: - /// - /// - Content-Disposition: form-data; name=#{name}; filename=#{filename} (HTTP Header) - /// - Content-Type: #{mimeType} (HTTP Header) - /// - Encoded file data - /// - Multipart form boundary - /// - /// - parameter fileURL: The URL of the file whose content will be encoded into the multipart form data. - /// - parameter name: The name to associate with the file content in the `Content-Disposition` HTTP header. - /// - parameter fileName: The filename to associate with the file content in the `Content-Disposition` HTTP header. - /// - parameter mimeType: The MIME type to associate with the file content in the `Content-Type` HTTP header. - public func append(_ fileURL: URL, withName name: String, fileName: String, mimeType: String) { - let headers = contentHeaders(withName: name, fileName: fileName, mimeType: mimeType) - - //============================================================ - // Check 1 - is file URL? - //============================================================ - - guard fileURL.isFileURL else { - setBodyPartError(withReason: .bodyPartURLInvalid(url: fileURL)) - return - } - - //============================================================ - // Check 2 - is file URL reachable? - //============================================================ - - do { - let isReachable = try fileURL.checkPromisedItemIsReachable() - guard isReachable else { - setBodyPartError(withReason: .bodyPartFileNotReachable(at: fileURL)) - return - } - } catch { - setBodyPartError(withReason: .bodyPartFileNotReachableWithError(atURL: fileURL, error: error)) - return - } - - //============================================================ - // Check 3 - is file URL a directory? - //============================================================ - - var isDirectory: ObjCBool = false - let path = fileURL.path - - guard FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory) && !isDirectory.boolValue else { - setBodyPartError(withReason: .bodyPartFileIsDirectory(at: fileURL)) - return - } - - //============================================================ - // Check 4 - can the file size be extracted? - //============================================================ - - let bodyContentLength: UInt64 - - do { - guard let fileSize = try FileManager.default.attributesOfItem(atPath: path)[.size] as? NSNumber else { - setBodyPartError(withReason: .bodyPartFileSizeNotAvailable(at: fileURL)) - return - } - - bodyContentLength = fileSize.uint64Value - } - catch { - setBodyPartError(withReason: .bodyPartFileSizeQueryFailedWithError(forURL: fileURL, error: error)) - return - } - - //============================================================ - // Check 5 - can a stream be created from file URL? - //============================================================ - - guard let stream = InputStream(url: fileURL) else { - setBodyPartError(withReason: .bodyPartInputStreamCreationFailed(for: fileURL)) - return - } - - append(stream, withLength: bodyContentLength, headers: headers) - } - - /// Creates a body part from the stream and appends it to the multipart form data object. - /// - /// The body part data will be encoded using the following format: - /// - /// - `Content-Disposition: form-data; name=#{name}; filename=#{filename}` (HTTP Header) - /// - `Content-Type: #{mimeType}` (HTTP Header) - /// - Encoded stream data - /// - Multipart form boundary - /// - /// - parameter stream: The input stream to encode in the multipart form data. - /// - parameter length: The content length of the stream. - /// - parameter name: The name to associate with the stream content in the `Content-Disposition` HTTP header. - /// - parameter fileName: The filename to associate with the stream content in the `Content-Disposition` HTTP header. - /// - parameter mimeType: The MIME type to associate with the stream content in the `Content-Type` HTTP header. - public func append( - _ stream: InputStream, - withLength length: UInt64, - name: String, - fileName: String, - mimeType: String) - { - let headers = contentHeaders(withName: name, fileName: fileName, mimeType: mimeType) - append(stream, withLength: length, headers: headers) - } - - /// Creates a body part with the headers, stream and length and appends it to the multipart form data object. - /// - /// The body part data will be encoded using the following format: - /// - /// - HTTP headers - /// - Encoded stream data - /// - Multipart form boundary - /// - /// - parameter stream: The input stream to encode in the multipart form data. - /// - parameter length: The content length of the stream. - /// - parameter headers: The HTTP headers for the body part. - public func append(_ stream: InputStream, withLength length: UInt64, headers: HTTPHeaders) { - let bodyPart = BodyPart(headers: headers, bodyStream: stream, bodyContentLength: length) - bodyParts.append(bodyPart) - } - - // MARK: - Data Encoding - - /// Encodes all the appended body parts into a single `Data` value. - /// - /// It is important to note that this method will load all the appended body parts into memory all at the same - /// time. This method should only be used when the encoded data will have a small memory footprint. For large data - /// cases, please use the `writeEncodedDataToDisk(fileURL:completionHandler:)` method. - /// - /// - throws: An `AFError` if encoding encounters an error. - /// - /// - returns: The encoded `Data` if encoding is successful. - public func encode() throws -> Data { - if let bodyPartError = bodyPartError { - throw bodyPartError - } - - var encoded = Data() - - bodyParts.first?.hasInitialBoundary = true - bodyParts.last?.hasFinalBoundary = true - - for bodyPart in bodyParts { - let encodedData = try encode(bodyPart) - encoded.append(encodedData) - } - - return encoded - } - - /// Writes the appended body parts into the given file URL. - /// - /// This process is facilitated by reading and writing with input and output streams, respectively. Thus, - /// this approach is very memory efficient and should be used for large body part data. - /// - /// - parameter fileURL: The file URL to write the multipart form data into. - /// - /// - throws: An `AFError` if encoding encounters an error. - public func writeEncodedData(to fileURL: URL) throws { - if let bodyPartError = bodyPartError { - throw bodyPartError - } - - if FileManager.default.fileExists(atPath: fileURL.path) { - throw AFError.multipartEncodingFailed(reason: .outputStreamFileAlreadyExists(at: fileURL)) - } else if !fileURL.isFileURL { - throw AFError.multipartEncodingFailed(reason: .outputStreamURLInvalid(url: fileURL)) - } - - guard let outputStream = OutputStream(url: fileURL, append: false) else { - throw AFError.multipartEncodingFailed(reason: .outputStreamCreationFailed(for: fileURL)) - } - - outputStream.open() - defer { outputStream.close() } - - self.bodyParts.first?.hasInitialBoundary = true - self.bodyParts.last?.hasFinalBoundary = true - - for bodyPart in self.bodyParts { - try write(bodyPart, to: outputStream) - } - } - - // MARK: - Private - Body Part Encoding - - private func encode(_ bodyPart: BodyPart) throws -> Data { - var encoded = Data() - - let initialData = bodyPart.hasInitialBoundary ? initialBoundaryData() : encapsulatedBoundaryData() - encoded.append(initialData) - - let headerData = encodeHeaders(for: bodyPart) - encoded.append(headerData) - - let bodyStreamData = try encodeBodyStream(for: bodyPart) - encoded.append(bodyStreamData) - - if bodyPart.hasFinalBoundary { - encoded.append(finalBoundaryData()) - } - - return encoded - } - - private func encodeHeaders(for bodyPart: BodyPart) -> Data { - var headerText = "" - - for (key, value) in bodyPart.headers { - headerText += "\(key): \(value)\(EncodingCharacters.crlf)" - } - headerText += EncodingCharacters.crlf - - return headerText.data(using: String.Encoding.utf8, allowLossyConversion: false)! - } - - private func encodeBodyStream(for bodyPart: BodyPart) throws -> Data { - let inputStream = bodyPart.bodyStream - inputStream.open() - defer { inputStream.close() } - - var encoded = Data() - - while inputStream.hasBytesAvailable { - var buffer = [UInt8](repeating: 0, count: streamBufferSize) - let bytesRead = inputStream.read(&buffer, maxLength: streamBufferSize) - - if let error = inputStream.streamError { - throw AFError.multipartEncodingFailed(reason: .inputStreamReadFailed(error: error)) - } - - if bytesRead > 0 { - encoded.append(buffer, count: bytesRead) - } else { - break - } - } - - return encoded - } - - // MARK: - Private - Writing Body Part to Output Stream - - private func write(_ bodyPart: BodyPart, to outputStream: OutputStream) throws { - try writeInitialBoundaryData(for: bodyPart, to: outputStream) - try writeHeaderData(for: bodyPart, to: outputStream) - try writeBodyStream(for: bodyPart, to: outputStream) - try writeFinalBoundaryData(for: bodyPart, to: outputStream) - } - - private func writeInitialBoundaryData(for bodyPart: BodyPart, to outputStream: OutputStream) throws { - let initialData = bodyPart.hasInitialBoundary ? initialBoundaryData() : encapsulatedBoundaryData() - return try write(initialData, to: outputStream) - } - - private func writeHeaderData(for bodyPart: BodyPart, to outputStream: OutputStream) throws { - let headerData = encodeHeaders(for: bodyPart) - return try write(headerData, to: outputStream) - } - - private func writeBodyStream(for bodyPart: BodyPart, to outputStream: OutputStream) throws { - let inputStream = bodyPart.bodyStream - - inputStream.open() - defer { inputStream.close() } - - while inputStream.hasBytesAvailable { - var buffer = [UInt8](repeating: 0, count: streamBufferSize) - let bytesRead = inputStream.read(&buffer, maxLength: streamBufferSize) - - if let streamError = inputStream.streamError { - throw AFError.multipartEncodingFailed(reason: .inputStreamReadFailed(error: streamError)) - } - - if bytesRead > 0 { - if buffer.count != bytesRead { - buffer = Array(buffer[0.. 0, outputStream.hasSpaceAvailable { - let bytesWritten = outputStream.write(buffer, maxLength: bytesToWrite) - - if let error = outputStream.streamError { - throw AFError.multipartEncodingFailed(reason: .outputStreamWriteFailed(error: error)) - } - - bytesToWrite -= bytesWritten - - if bytesToWrite > 0 { - buffer = Array(buffer[bytesWritten.. String { - if - let id = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as CFString, nil)?.takeRetainedValue(), - let contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?.takeRetainedValue() - { - return contentType as String - } - - return "application/octet-stream" - } - - // MARK: - Private - Content Headers - - private func contentHeaders(withName name: String, fileName: String? = nil, mimeType: String? = nil) -> [String: String] { - var disposition = "form-data; name=\"\(name)\"" - if let fileName = fileName { disposition += "; filename=\"\(fileName)\"" } - - var headers = ["Content-Disposition": disposition] - if let mimeType = mimeType { headers["Content-Type"] = mimeType } - - return headers - } - - // MARK: - Private - Boundary Encoding - - private func initialBoundaryData() -> Data { - return BoundaryGenerator.boundaryData(forBoundaryType: .initial, boundary: boundary) - } - - private func encapsulatedBoundaryData() -> Data { - return BoundaryGenerator.boundaryData(forBoundaryType: .encapsulated, boundary: boundary) - } - - private func finalBoundaryData() -> Data { - return BoundaryGenerator.boundaryData(forBoundaryType: .final, boundary: boundary) - } - - // MARK: - Private - Errors - - private func setBodyPartError(withReason reason: AFError.MultipartEncodingFailureReason) { - guard bodyPartError == nil else { return } - bodyPartError = AFError.multipartEncodingFailed(reason: reason) - } -} diff --git a/Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift b/Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift deleted file mode 100644 index 5470eec..0000000 --- a/Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift +++ /dev/null @@ -1,235 +0,0 @@ -// -// NetworkReachabilityManager.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -#if !os(watchOS) - -import Foundation -import SystemConfiguration - -/// The `NetworkReachabilityManager` class listens for reachability changes of hosts and addresses for both WWAN and -/// WiFi network interfaces. -/// -/// Reachability can be used to determine background information about why a network operation failed, or to retry -/// network requests when a connection is established. It should not be used to prevent a user from initiating a network -/// request, as it's possible that an initial request may be required to establish reachability. -open class NetworkReachabilityManager { - /// Defines the various states of network reachability. - /// - /// - unknown: It is unknown whether the network is reachable. - /// - notReachable: The network is not reachable. - /// - reachable: The network is reachable. - public enum NetworkReachabilityStatus { - case unknown - case notReachable - case reachable(ConnectionType) - } - - /// Defines the various connection types detected by reachability flags. - /// - /// - ethernetOrWiFi: The connection type is either over Ethernet or WiFi. - /// - wwan: The connection type is a WWAN connection. - public enum ConnectionType { - case ethernetOrWiFi - case wwan - } - - /// A closure executed when the network reachability status changes. The closure takes a single argument: the - /// network reachability status. - public typealias Listener = (NetworkReachabilityStatus) -> Void - - // MARK: - Properties - - /// Whether the network is currently reachable. - open var isReachable: Bool { return isReachableOnWWAN || isReachableOnEthernetOrWiFi } - - /// Whether the network is currently reachable over the WWAN interface. - open var isReachableOnWWAN: Bool { return networkReachabilityStatus == .reachable(.wwan) } - - /// Whether the network is currently reachable over Ethernet or WiFi interface. - open var isReachableOnEthernetOrWiFi: Bool { return networkReachabilityStatus == .reachable(.ethernetOrWiFi) } - - /// The current network reachability status. - open var networkReachabilityStatus: NetworkReachabilityStatus { - guard let flags = self.flags else { return .unknown } - return networkReachabilityStatusForFlags(flags) - } - - /// The dispatch queue to execute the `listener` closure on. - open var listenerQueue: DispatchQueue = DispatchQueue.main - - /// A closure executed when the network reachability status changes. - open var listener: Listener? - - open var flags: SCNetworkReachabilityFlags? { - var flags = SCNetworkReachabilityFlags() - - if SCNetworkReachabilityGetFlags(reachability, &flags) { - return flags - } - - return nil - } - - private let reachability: SCNetworkReachability - open var previousFlags: SCNetworkReachabilityFlags - - // MARK: - Initialization - - /// Creates a `NetworkReachabilityManager` instance with the specified host. - /// - /// - parameter host: The host used to evaluate network reachability. - /// - /// - returns: The new `NetworkReachabilityManager` instance. - public convenience init?(host: String) { - guard let reachability = SCNetworkReachabilityCreateWithName(nil, host) else { return nil } - self.init(reachability: reachability) - } - - /// Creates a `NetworkReachabilityManager` instance that monitors the address 0.0.0.0. - /// - /// Reachability treats the 0.0.0.0 address as a special token that causes it to monitor the general routing - /// status of the device, both IPv4 and IPv6. - /// - /// - returns: The new `NetworkReachabilityManager` instance. - public convenience init?() { - var address = sockaddr_in() - address.sin_len = UInt8(MemoryLayout.size) - address.sin_family = sa_family_t(AF_INET) - - guard let reachability = withUnsafePointer(to: &address, { pointer in - return pointer.withMemoryRebound(to: sockaddr.self, capacity: MemoryLayout.size) { - return SCNetworkReachabilityCreateWithAddress(nil, $0) - } - }) else { return nil } - - self.init(reachability: reachability) - } - - private init(reachability: SCNetworkReachability) { - self.reachability = reachability - - // Set the previous flags to an unreserved value to represent unknown status - self.previousFlags = SCNetworkReachabilityFlags(rawValue: 1 << 30) - } - - deinit { - stopListening() - } - - // MARK: - Listening - - /// Starts listening for changes in network reachability status. - /// - /// - returns: `true` if listening was started successfully, `false` otherwise. - @discardableResult - open func startListening() -> Bool { - var context = SCNetworkReachabilityContext(version: 0, info: nil, retain: nil, release: nil, copyDescription: nil) - context.info = Unmanaged.passUnretained(self).toOpaque() - - let callbackEnabled = SCNetworkReachabilitySetCallback( - reachability, - { (_, flags, info) in - let reachability = Unmanaged.fromOpaque(info!).takeUnretainedValue() - reachability.notifyListener(flags) - }, - &context - ) - - let queueEnabled = SCNetworkReachabilitySetDispatchQueue(reachability, listenerQueue) - - listenerQueue.async { - guard let flags = self.flags else { return } - self.notifyListener(flags) - } - - return callbackEnabled && queueEnabled - } - - /// Stops listening for changes in network reachability status. - open func stopListening() { - SCNetworkReachabilitySetCallback(reachability, nil, nil) - SCNetworkReachabilitySetDispatchQueue(reachability, nil) - } - - // MARK: - Internal - Listener Notification - - func notifyListener(_ flags: SCNetworkReachabilityFlags) { - guard previousFlags != flags else { return } - previousFlags = flags - - listener?(networkReachabilityStatusForFlags(flags)) - } - - // MARK: - Internal - Network Reachability Status - - func networkReachabilityStatusForFlags(_ flags: SCNetworkReachabilityFlags) -> NetworkReachabilityStatus { - guard isNetworkReachable(with: flags) else { return .notReachable } - - var networkStatus: NetworkReachabilityStatus = .reachable(.ethernetOrWiFi) - - #if os(iOS) - if flags.contains(.isWWAN) { networkStatus = .reachable(.wwan) } - #endif - - return networkStatus - } - - func isNetworkReachable(with flags: SCNetworkReachabilityFlags) -> Bool { - let isReachable = flags.contains(.reachable) - let needsConnection = flags.contains(.connectionRequired) - let canConnectAutomatically = flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic) - let canConnectWithoutUserInteraction = canConnectAutomatically && !flags.contains(.interventionRequired) - - return isReachable && (!needsConnection || canConnectWithoutUserInteraction) - } -} - -// MARK: - - -extension NetworkReachabilityManager.NetworkReachabilityStatus: Equatable {} - -/// Returns whether the two network reachability status values are equal. -/// -/// - parameter lhs: The left-hand side value to compare. -/// - parameter rhs: The right-hand side value to compare. -/// -/// - returns: `true` if the two values are equal, `false` otherwise. -public func ==( - lhs: NetworkReachabilityManager.NetworkReachabilityStatus, - rhs: NetworkReachabilityManager.NetworkReachabilityStatus) - -> Bool -{ - switch (lhs, rhs) { - case (.unknown, .unknown): - return true - case (.notReachable, .notReachable): - return true - case let (.reachable(lhsConnectionType), .reachable(rhsConnectionType)): - return lhsConnectionType == rhsConnectionType - default: - return false - } -} - -#endif diff --git a/Example/Pods/Alamofire/Source/Notifications.swift b/Example/Pods/Alamofire/Source/Notifications.swift deleted file mode 100644 index e1ac31b..0000000 --- a/Example/Pods/Alamofire/Source/Notifications.swift +++ /dev/null @@ -1,55 +0,0 @@ -// -// Notifications.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -extension Notification.Name { - /// Used as a namespace for all `URLSessionTask` related notifications. - public struct Task { - /// Posted when a `URLSessionTask` is resumed. The notification `object` contains the resumed `URLSessionTask`. - public static let DidResume = Notification.Name(rawValue: "org.alamofire.notification.name.task.didResume") - - /// Posted when a `URLSessionTask` is suspended. The notification `object` contains the suspended `URLSessionTask`. - public static let DidSuspend = Notification.Name(rawValue: "org.alamofire.notification.name.task.didSuspend") - - /// Posted when a `URLSessionTask` is cancelled. The notification `object` contains the cancelled `URLSessionTask`. - public static let DidCancel = Notification.Name(rawValue: "org.alamofire.notification.name.task.didCancel") - - /// Posted when a `URLSessionTask` is completed. The notification `object` contains the completed `URLSessionTask`. - public static let DidComplete = Notification.Name(rawValue: "org.alamofire.notification.name.task.didComplete") - } -} - -// MARK: - - -extension Notification { - /// Used as a namespace for all `Notification` user info dictionary keys. - public struct Key { - /// User info dictionary key representing the `URLSessionTask` associated with the notification. - public static let Task = "org.alamofire.notification.key.task" - - /// User info dictionary key representing the responseData associated with the notification. - public static let ResponseData = "org.alamofire.notification.key.responseData" - } -} diff --git a/Example/Pods/Alamofire/Source/ParameterEncoding.swift b/Example/Pods/Alamofire/Source/ParameterEncoding.swift deleted file mode 100644 index 6195809..0000000 --- a/Example/Pods/Alamofire/Source/ParameterEncoding.swift +++ /dev/null @@ -1,483 +0,0 @@ -// -// ParameterEncoding.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// HTTP method definitions. -/// -/// See https://tools.ietf.org/html/rfc7231#section-4.3 -public enum HTTPMethod: String { - case options = "OPTIONS" - case get = "GET" - case head = "HEAD" - case post = "POST" - case put = "PUT" - case patch = "PATCH" - case delete = "DELETE" - case trace = "TRACE" - case connect = "CONNECT" -} - -// MARK: - - -/// A dictionary of parameters to apply to a `URLRequest`. -public typealias Parameters = [String: Any] - -/// A type used to define how a set of parameters are applied to a `URLRequest`. -public protocol ParameterEncoding { - /// Creates a URL request by encoding parameters and applying them onto an existing request. - /// - /// - parameter urlRequest: The request to have parameters applied. - /// - parameter parameters: The parameters to apply. - /// - /// - throws: An `AFError.parameterEncodingFailed` error if encoding fails. - /// - /// - returns: The encoded request. - func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest -} - -// MARK: - - -/// Creates a url-encoded query string to be set as or appended to any existing URL query string or set as the HTTP -/// body of the URL request. Whether the query string is set or appended to any existing URL query string or set as -/// the HTTP body depends on the destination of the encoding. -/// -/// The `Content-Type` HTTP header field of an encoded request with HTTP body is set to -/// `application/x-www-form-urlencoded; charset=utf-8`. -/// -/// There is no published specification for how to encode collection types. By default the convention of appending -/// `[]` to the key for array values (`foo[]=1&foo[]=2`), and appending the key surrounded by square brackets for -/// nested dictionary values (`foo[bar]=baz`) is used. Optionally, `ArrayEncoding` can be used to omit the -/// square brackets appended to array keys. -/// -/// `BoolEncoding` can be used to configure how boolean values are encoded. The default behavior is to encode -/// `true` as 1 and `false` as 0. -public struct URLEncoding: ParameterEncoding { - - // MARK: Helper Types - - /// Defines whether the url-encoded query string is applied to the existing query string or HTTP body of the - /// resulting URL request. - /// - /// - methodDependent: Applies encoded query string result to existing query string for `GET`, `HEAD` and `DELETE` - /// requests and sets as the HTTP body for requests with any other HTTP method. - /// - queryString: Sets or appends encoded query string result to existing query string. - /// - httpBody: Sets encoded query string result as the HTTP body of the URL request. - public enum Destination { - case methodDependent, queryString, httpBody - } - - /// Configures how `Array` parameters are encoded. - /// - /// - brackets: An empty set of square brackets is appended to the key for every value. - /// This is the default behavior. - /// - noBrackets: No brackets are appended. The key is encoded as is. - public enum ArrayEncoding { - case brackets, noBrackets - - func encode(key: String) -> String { - switch self { - case .brackets: - return "\(key)[]" - case .noBrackets: - return key - } - } - } - - /// Configures how `Bool` parameters are encoded. - /// - /// - numeric: Encode `true` as `1` and `false` as `0`. This is the default behavior. - /// - literal: Encode `true` and `false` as string literals. - public enum BoolEncoding { - case numeric, literal - - func encode(value: Bool) -> String { - switch self { - case .numeric: - return value ? "1" : "0" - case .literal: - return value ? "true" : "false" - } - } - } - - // MARK: Properties - - /// Returns a default `URLEncoding` instance. - public static var `default`: URLEncoding { return URLEncoding() } - - /// Returns a `URLEncoding` instance with a `.methodDependent` destination. - public static var methodDependent: URLEncoding { return URLEncoding() } - - /// Returns a `URLEncoding` instance with a `.queryString` destination. - public static var queryString: URLEncoding { return URLEncoding(destination: .queryString) } - - /// Returns a `URLEncoding` instance with an `.httpBody` destination. - public static var httpBody: URLEncoding { return URLEncoding(destination: .httpBody) } - - /// The destination defining where the encoded query string is to be applied to the URL request. - public let destination: Destination - - /// The encoding to use for `Array` parameters. - public let arrayEncoding: ArrayEncoding - - /// The encoding to use for `Bool` parameters. - public let boolEncoding: BoolEncoding - - // MARK: Initialization - - /// Creates a `URLEncoding` instance using the specified destination. - /// - /// - parameter destination: The destination defining where the encoded query string is to be applied. - /// - parameter arrayEncoding: The encoding to use for `Array` parameters. - /// - parameter boolEncoding: The encoding to use for `Bool` parameters. - /// - /// - returns: The new `URLEncoding` instance. - public init(destination: Destination = .methodDependent, arrayEncoding: ArrayEncoding = .brackets, boolEncoding: BoolEncoding = .numeric) { - self.destination = destination - self.arrayEncoding = arrayEncoding - self.boolEncoding = boolEncoding - } - - // MARK: Encoding - - /// Creates a URL request by encoding parameters and applying them onto an existing request. - /// - /// - parameter urlRequest: The request to have parameters applied. - /// - parameter parameters: The parameters to apply. - /// - /// - throws: An `Error` if the encoding process encounters an error. - /// - /// - returns: The encoded request. - public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { - var urlRequest = try urlRequest.asURLRequest() - - guard let parameters = parameters else { return urlRequest } - - if let method = HTTPMethod(rawValue: urlRequest.httpMethod ?? "GET"), encodesParametersInURL(with: method) { - guard let url = urlRequest.url else { - throw AFError.parameterEncodingFailed(reason: .missingURL) - } - - if var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false), !parameters.isEmpty { - let percentEncodedQuery = (urlComponents.percentEncodedQuery.map { $0 + "&" } ?? "") + query(parameters) - urlComponents.percentEncodedQuery = percentEncodedQuery - urlRequest.url = urlComponents.url - } - } else { - if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { - urlRequest.setValue("application/x-www-form-urlencoded; charset=utf-8", forHTTPHeaderField: "Content-Type") - } - - urlRequest.httpBody = query(parameters).data(using: .utf8, allowLossyConversion: false) - } - - return urlRequest - } - - /// Creates percent-escaped, URL encoded query string components from the given key-value pair using recursion. - /// - /// - parameter key: The key of the query component. - /// - parameter value: The value of the query component. - /// - /// - returns: The percent-escaped, URL encoded query string components. - public func queryComponents(fromKey key: String, value: Any) -> [(String, String)] { - var components: [(String, String)] = [] - - if let dictionary = value as? [String: Any] { - for (nestedKey, value) in dictionary { - components += queryComponents(fromKey: "\(key)[\(nestedKey)]", value: value) - } - } else if let array = value as? [Any] { - for value in array { - components += queryComponents(fromKey: arrayEncoding.encode(key: key), value: value) - } - } else if let value = value as? NSNumber { - if value.isBool { - components.append((escape(key), escape(boolEncoding.encode(value: value.boolValue)))) - } else { - components.append((escape(key), escape("\(value)"))) - } - } else if let bool = value as? Bool { - components.append((escape(key), escape(boolEncoding.encode(value: bool)))) - } else { - components.append((escape(key), escape("\(value)"))) - } - - return components - } - - /// Returns a percent-escaped string following RFC 3986 for a query string key or value. - /// - /// RFC 3986 states that the following characters are "reserved" characters. - /// - /// - General Delimiters: ":", "#", "[", "]", "@", "?", "/" - /// - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" - /// - /// In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow - /// query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" - /// should be percent-escaped in the query string. - /// - /// - parameter string: The string to be percent-escaped. - /// - /// - returns: The percent-escaped string. - public func escape(_ string: String) -> String { - let generalDelimitersToEncode = ":#[]@" // does not include "?" or "/" due to RFC 3986 - Section 3.4 - let subDelimitersToEncode = "!$&'()*+,;=" - - var allowedCharacterSet = CharacterSet.urlQueryAllowed - allowedCharacterSet.remove(charactersIn: "\(generalDelimitersToEncode)\(subDelimitersToEncode)") - - var escaped = "" - - //========================================================================================================== - // - // Batching is required for escaping due to an internal bug in iOS 8.1 and 8.2. Encoding more than a few - // hundred Chinese characters causes various malloc error crashes. To avoid this issue until iOS 8 is no - // longer supported, batching MUST be used for encoding. This introduces roughly a 20% overhead. For more - // info, please refer to: - // - // - https://github.com/Alamofire/Alamofire/issues/206 - // - //========================================================================================================== - - if #available(iOS 8.3, *) { - escaped = string.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet) ?? string - } else { - let batchSize = 50 - var index = string.startIndex - - while index != string.endIndex { - let startIndex = index - let endIndex = string.index(index, offsetBy: batchSize, limitedBy: string.endIndex) ?? string.endIndex - let range = startIndex.. String { - var components: [(String, String)] = [] - - for key in parameters.keys.sorted(by: <) { - let value = parameters[key]! - components += queryComponents(fromKey: key, value: value) - } - return components.map { "\($0)=\($1)" }.joined(separator: "&") - } - - private func encodesParametersInURL(with method: HTTPMethod) -> Bool { - switch destination { - case .queryString: - return true - case .httpBody: - return false - default: - break - } - - switch method { - case .get, .head, .delete: - return true - default: - return false - } - } -} - -// MARK: - - -/// Uses `JSONSerialization` to create a JSON representation of the parameters object, which is set as the body of the -/// request. The `Content-Type` HTTP header field of an encoded request is set to `application/json`. -public struct JSONEncoding: ParameterEncoding { - - // MARK: Properties - - /// Returns a `JSONEncoding` instance with default writing options. - public static var `default`: JSONEncoding { return JSONEncoding() } - - /// Returns a `JSONEncoding` instance with `.prettyPrinted` writing options. - public static var prettyPrinted: JSONEncoding { return JSONEncoding(options: .prettyPrinted) } - - /// The options for writing the parameters as JSON data. - public let options: JSONSerialization.WritingOptions - - // MARK: Initialization - - /// Creates a `JSONEncoding` instance using the specified options. - /// - /// - parameter options: The options for writing the parameters as JSON data. - /// - /// - returns: The new `JSONEncoding` instance. - public init(options: JSONSerialization.WritingOptions = []) { - self.options = options - } - - // MARK: Encoding - - /// Creates a URL request by encoding parameters and applying them onto an existing request. - /// - /// - parameter urlRequest: The request to have parameters applied. - /// - parameter parameters: The parameters to apply. - /// - /// - throws: An `Error` if the encoding process encounters an error. - /// - /// - returns: The encoded request. - public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { - var urlRequest = try urlRequest.asURLRequest() - - guard let parameters = parameters else { return urlRequest } - - do { - let data = try JSONSerialization.data(withJSONObject: parameters, options: options) - - if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { - urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") - } - - urlRequest.httpBody = data - } catch { - throw AFError.parameterEncodingFailed(reason: .jsonEncodingFailed(error: error)) - } - - return urlRequest - } - - /// Creates a URL request by encoding the JSON object and setting the resulting data on the HTTP body. - /// - /// - parameter urlRequest: The request to apply the JSON object to. - /// - parameter jsonObject: The JSON object to apply to the request. - /// - /// - throws: An `Error` if the encoding process encounters an error. - /// - /// - returns: The encoded request. - public func encode(_ urlRequest: URLRequestConvertible, withJSONObject jsonObject: Any? = nil) throws -> URLRequest { - var urlRequest = try urlRequest.asURLRequest() - - guard let jsonObject = jsonObject else { return urlRequest } - - do { - let data = try JSONSerialization.data(withJSONObject: jsonObject, options: options) - - if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { - urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") - } - - urlRequest.httpBody = data - } catch { - throw AFError.parameterEncodingFailed(reason: .jsonEncodingFailed(error: error)) - } - - return urlRequest - } -} - -// MARK: - - -/// Uses `PropertyListSerialization` to create a plist representation of the parameters object, according to the -/// associated format and write options values, which is set as the body of the request. The `Content-Type` HTTP header -/// field of an encoded request is set to `application/x-plist`. -public struct PropertyListEncoding: ParameterEncoding { - - // MARK: Properties - - /// Returns a default `PropertyListEncoding` instance. - public static var `default`: PropertyListEncoding { return PropertyListEncoding() } - - /// Returns a `PropertyListEncoding` instance with xml formatting and default writing options. - public static var xml: PropertyListEncoding { return PropertyListEncoding(format: .xml) } - - /// Returns a `PropertyListEncoding` instance with binary formatting and default writing options. - public static var binary: PropertyListEncoding { return PropertyListEncoding(format: .binary) } - - /// The property list serialization format. - public let format: PropertyListSerialization.PropertyListFormat - - /// The options for writing the parameters as plist data. - public let options: PropertyListSerialization.WriteOptions - - // MARK: Initialization - - /// Creates a `PropertyListEncoding` instance using the specified format and options. - /// - /// - parameter format: The property list serialization format. - /// - parameter options: The options for writing the parameters as plist data. - /// - /// - returns: The new `PropertyListEncoding` instance. - public init( - format: PropertyListSerialization.PropertyListFormat = .xml, - options: PropertyListSerialization.WriteOptions = 0) - { - self.format = format - self.options = options - } - - // MARK: Encoding - - /// Creates a URL request by encoding parameters and applying them onto an existing request. - /// - /// - parameter urlRequest: The request to have parameters applied. - /// - parameter parameters: The parameters to apply. - /// - /// - throws: An `Error` if the encoding process encounters an error. - /// - /// - returns: The encoded request. - public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { - var urlRequest = try urlRequest.asURLRequest() - - guard let parameters = parameters else { return urlRequest } - - do { - let data = try PropertyListSerialization.data( - fromPropertyList: parameters, - format: format, - options: options - ) - - if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { - urlRequest.setValue("application/x-plist", forHTTPHeaderField: "Content-Type") - } - - urlRequest.httpBody = data - } catch { - throw AFError.parameterEncodingFailed(reason: .propertyListEncodingFailed(error: error)) - } - - return urlRequest - } -} - -// MARK: - - -extension NSNumber { - fileprivate var isBool: Bool { return CFBooleanGetTypeID() == CFGetTypeID(self) } -} diff --git a/Example/Pods/Alamofire/Source/Request.swift b/Example/Pods/Alamofire/Source/Request.swift deleted file mode 100644 index a2efaa0..0000000 --- a/Example/Pods/Alamofire/Source/Request.swift +++ /dev/null @@ -1,649 +0,0 @@ -// -// Request.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// A type that can inspect and optionally adapt a `URLRequest` in some manner if necessary. -public protocol RequestAdapter { - /// Inspects and adapts the specified `URLRequest` in some manner if necessary and returns the result. - /// - /// - parameter urlRequest: The URL request to adapt. - /// - /// - throws: An `Error` if the adaptation encounters an error. - /// - /// - returns: The adapted `URLRequest`. - func adapt(_ urlRequest: URLRequest) throws -> URLRequest -} - -// MARK: - - -/// A closure executed when the `RequestRetrier` determines whether a `Request` should be retried or not. -public typealias RequestRetryCompletion = (_ shouldRetry: Bool, _ timeDelay: TimeInterval) -> Void - -/// A type that determines whether a request should be retried after being executed by the specified session manager -/// and encountering an error. -public protocol RequestRetrier { - /// Determines whether the `Request` should be retried by calling the `completion` closure. - /// - /// This operation is fully asynchronous. Any amount of time can be taken to determine whether the request needs - /// to be retried. The one requirement is that the completion closure is called to ensure the request is properly - /// cleaned up after. - /// - /// - parameter manager: The session manager the request was executed on. - /// - parameter request: The request that failed due to the encountered error. - /// - parameter error: The error encountered when executing the request. - /// - parameter completion: The completion closure to be executed when retry decision has been determined. - func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion) -} - -// MARK: - - -protocol TaskConvertible { - func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask -} - -/// A dictionary of headers to apply to a `URLRequest`. -public typealias HTTPHeaders = [String: String] - -// MARK: - - -/// Responsible for sending a request and receiving the response and associated data from the server, as well as -/// managing its underlying `URLSessionTask`. -open class Request { - - // MARK: Helper Types - - /// A closure executed when monitoring upload or download progress of a request. - public typealias ProgressHandler = (Progress) -> Void - - enum RequestTask { - case data(TaskConvertible?, URLSessionTask?) - case download(TaskConvertible?, URLSessionTask?) - case upload(TaskConvertible?, URLSessionTask?) - case stream(TaskConvertible?, URLSessionTask?) - } - - // MARK: Properties - - /// The delegate for the underlying task. - open internal(set) var delegate: TaskDelegate { - get { - taskDelegateLock.lock() ; defer { taskDelegateLock.unlock() } - return taskDelegate - } - set { - taskDelegateLock.lock() ; defer { taskDelegateLock.unlock() } - taskDelegate = newValue - } - } - - /// The underlying task. - open var task: URLSessionTask? { return delegate.task } - - /// The session belonging to the underlying task. - public let session: URLSession - - /// The request sent or to be sent to the server. - open var request: URLRequest? { return task?.originalRequest } - - /// The response received from the server, if any. - open var response: HTTPURLResponse? { return task?.response as? HTTPURLResponse } - - /// The number of times the request has been retried. - open internal(set) var retryCount: UInt = 0 - - let originalTask: TaskConvertible? - - var startTime: CFAbsoluteTime? - var endTime: CFAbsoluteTime? - - var validations: [() -> Void] = [] - - private var taskDelegate: TaskDelegate - private var taskDelegateLock = NSLock() - - // MARK: Lifecycle - - init(session: URLSession, requestTask: RequestTask, error: Error? = nil) { - self.session = session - - switch requestTask { - case .data(let originalTask, let task): - taskDelegate = DataTaskDelegate(task: task) - self.originalTask = originalTask - case .download(let originalTask, let task): - taskDelegate = DownloadTaskDelegate(task: task) - self.originalTask = originalTask - case .upload(let originalTask, let task): - taskDelegate = UploadTaskDelegate(task: task) - self.originalTask = originalTask - case .stream(let originalTask, let task): - taskDelegate = TaskDelegate(task: task) - self.originalTask = originalTask - } - - delegate.error = error - delegate.queue.addOperation { self.endTime = CFAbsoluteTimeGetCurrent() } - } - - // MARK: Authentication - - /// Associates an HTTP Basic credential with the request. - /// - /// - parameter user: The user. - /// - parameter password: The password. - /// - parameter persistence: The URL credential persistence. `.ForSession` by default. - /// - /// - returns: The request. - @discardableResult - open func authenticate( - user: String, - password: String, - persistence: URLCredential.Persistence = .forSession) - -> Self - { - let credential = URLCredential(user: user, password: password, persistence: persistence) - return authenticate(usingCredential: credential) - } - - /// Associates a specified credential with the request. - /// - /// - parameter credential: The credential. - /// - /// - returns: The request. - @discardableResult - open func authenticate(usingCredential credential: URLCredential) -> Self { - delegate.credential = credential - return self - } - - /// Returns a base64 encoded basic authentication credential as an authorization header tuple. - /// - /// - parameter user: The user. - /// - parameter password: The password. - /// - /// - returns: A tuple with Authorization header and credential value if encoding succeeds, `nil` otherwise. - open class func authorizationHeader(user: String, password: String) -> (key: String, value: String)? { - guard let data = "\(user):\(password)".data(using: .utf8) else { return nil } - - let credential = data.base64EncodedString(options: []) - - return (key: "Authorization", value: "Basic \(credential)") - } - - // MARK: State - - /// Resumes the request. - open func resume() { - guard let task = task else { delegate.queue.isSuspended = false ; return } - - if startTime == nil { startTime = CFAbsoluteTimeGetCurrent() } - - task.resume() - - NotificationCenter.default.post( - name: Notification.Name.Task.DidResume, - object: self, - userInfo: [Notification.Key.Task: task] - ) - } - - /// Suspends the request. - open func suspend() { - guard let task = task else { return } - - task.suspend() - - NotificationCenter.default.post( - name: Notification.Name.Task.DidSuspend, - object: self, - userInfo: [Notification.Key.Task: task] - ) - } - - /// Cancels the request. - open func cancel() { - guard let task = task else { return } - - task.cancel() - - NotificationCenter.default.post( - name: Notification.Name.Task.DidCancel, - object: self, - userInfo: [Notification.Key.Task: task] - ) - } -} - -// MARK: - CustomStringConvertible - -extension Request: CustomStringConvertible { - /// The textual representation used when written to an output stream, which includes the HTTP method and URL, as - /// well as the response status code if a response has been received. - open var description: String { - var components: [String] = [] - - if let HTTPMethod = request?.httpMethod { - components.append(HTTPMethod) - } - - if let urlString = request?.url?.absoluteString { - components.append(urlString) - } - - if let response = response { - components.append("(\(response.statusCode))") - } - - return components.joined(separator: " ") - } -} - -// MARK: - CustomDebugStringConvertible - -extension Request: CustomDebugStringConvertible { - /// The textual representation used when written to an output stream, in the form of a cURL command. - open var debugDescription: String { - return cURLRepresentation() - } - - func cURLRepresentation() -> String { - var components = ["$ curl -v"] - - guard let request = self.request, - let url = request.url, - let host = url.host - else { - return "$ curl command could not be created" - } - - if let httpMethod = request.httpMethod, httpMethod != "GET" { - components.append("-X \(httpMethod)") - } - - if let credentialStorage = self.session.configuration.urlCredentialStorage { - let protectionSpace = URLProtectionSpace( - host: host, - port: url.port ?? 0, - protocol: url.scheme, - realm: host, - authenticationMethod: NSURLAuthenticationMethodHTTPBasic - ) - - if let credentials = credentialStorage.credentials(for: protectionSpace)?.values { - for credential in credentials { - guard let user = credential.user, let password = credential.password else { continue } - components.append("-u \(user):\(password)") - } - } else { - if let credential = delegate.credential, let user = credential.user, let password = credential.password { - components.append("-u \(user):\(password)") - } - } - } - - if session.configuration.httpShouldSetCookies { - if - let cookieStorage = session.configuration.httpCookieStorage, - let cookies = cookieStorage.cookies(for: url), !cookies.isEmpty - { - let string = cookies.reduce("") { $0 + "\($1.name)=\($1.value);" } - - #if swift(>=3.2) - components.append("-b \"\(string[.. URLSessionTask { - do { - let urlRequest = try self.urlRequest.adapt(using: adapter) - return queue.sync { session.dataTask(with: urlRequest) } - } catch { - throw AdaptError(error: error) - } - } - } - - // MARK: Properties - - /// The request sent or to be sent to the server. - open override var request: URLRequest? { - if let request = super.request { return request } - if let requestable = originalTask as? Requestable { return requestable.urlRequest } - - return nil - } - - /// The progress of fetching the response data from the server for the request. - open var progress: Progress { return dataDelegate.progress } - - var dataDelegate: DataTaskDelegate { return delegate as! DataTaskDelegate } - - // MARK: Stream - - /// Sets a closure to be called periodically during the lifecycle of the request as data is read from the server. - /// - /// This closure returns the bytes most recently received from the server, not including data from previous calls. - /// If this closure is set, data will only be available within this closure, and will not be saved elsewhere. It is - /// also important to note that the server data in any `Response` object will be `nil`. - /// - /// - parameter closure: The code to be executed periodically during the lifecycle of the request. - /// - /// - returns: The request. - @discardableResult - open func stream(closure: ((Data) -> Void)? = nil) -> Self { - dataDelegate.dataStream = closure - return self - } - - // MARK: Progress - - /// Sets a closure to be called periodically during the lifecycle of the `Request` as data is read from the server. - /// - /// - parameter queue: The dispatch queue to execute the closure on. - /// - parameter closure: The code to be executed periodically as data is read from the server. - /// - /// - returns: The request. - @discardableResult - open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self { - dataDelegate.progressHandler = (closure, queue) - return self - } -} - -// MARK: - - -/// Specific type of `Request` that manages an underlying `URLSessionDownloadTask`. -open class DownloadRequest: Request { - - // MARK: Helper Types - - /// A collection of options to be executed prior to moving a downloaded file from the temporary URL to the - /// destination URL. - public struct DownloadOptions: OptionSet { - /// Returns the raw bitmask value of the option and satisfies the `RawRepresentable` protocol. - public let rawValue: UInt - - /// A `DownloadOptions` flag that creates intermediate directories for the destination URL if specified. - public static let createIntermediateDirectories = DownloadOptions(rawValue: 1 << 0) - - /// A `DownloadOptions` flag that removes a previous file from the destination URL if specified. - public static let removePreviousFile = DownloadOptions(rawValue: 1 << 1) - - /// Creates a `DownloadFileDestinationOptions` instance with the specified raw value. - /// - /// - parameter rawValue: The raw bitmask value for the option. - /// - /// - returns: A new log level instance. - public init(rawValue: UInt) { - self.rawValue = rawValue - } - } - - /// A closure executed once a download request has successfully completed in order to determine where to move the - /// temporary file written to during the download process. The closure takes two arguments: the temporary file URL - /// and the URL response, and returns a two arguments: the file URL where the temporary file should be moved and - /// the options defining how the file should be moved. - public typealias DownloadFileDestination = ( - _ temporaryURL: URL, - _ response: HTTPURLResponse) - -> (destinationURL: URL, options: DownloadOptions) - - enum Downloadable: TaskConvertible { - case request(URLRequest) - case resumeData(Data) - - func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask { - do { - let task: URLSessionTask - - switch self { - case let .request(urlRequest): - let urlRequest = try urlRequest.adapt(using: adapter) - task = queue.sync { session.downloadTask(with: urlRequest) } - case let .resumeData(resumeData): - task = queue.sync { session.downloadTask(withResumeData: resumeData) } - } - - return task - } catch { - throw AdaptError(error: error) - } - } - } - - // MARK: Properties - - /// The request sent or to be sent to the server. - open override var request: URLRequest? { - if let request = super.request { return request } - - if let downloadable = originalTask as? Downloadable, case let .request(urlRequest) = downloadable { - return urlRequest - } - - return nil - } - - /// The resume data of the underlying download task if available after a failure. - open var resumeData: Data? { return downloadDelegate.resumeData } - - /// The progress of downloading the response data from the server for the request. - open var progress: Progress { return downloadDelegate.progress } - - var downloadDelegate: DownloadTaskDelegate { return delegate as! DownloadTaskDelegate } - - // MARK: State - - /// Cancels the request. - open override func cancel() { - downloadDelegate.downloadTask.cancel { self.downloadDelegate.resumeData = $0 } - - NotificationCenter.default.post( - name: Notification.Name.Task.DidCancel, - object: self, - userInfo: [Notification.Key.Task: task as Any] - ) - } - - // MARK: Progress - - /// Sets a closure to be called periodically during the lifecycle of the `Request` as data is read from the server. - /// - /// - parameter queue: The dispatch queue to execute the closure on. - /// - parameter closure: The code to be executed periodically as data is read from the server. - /// - /// - returns: The request. - @discardableResult - open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self { - downloadDelegate.progressHandler = (closure, queue) - return self - } - - // MARK: Destination - - /// Creates a download file destination closure which uses the default file manager to move the temporary file to a - /// file URL in the first available directory with the specified search path directory and search path domain mask. - /// - /// - parameter directory: The search path directory. `.DocumentDirectory` by default. - /// - parameter domain: The search path domain mask. `.UserDomainMask` by default. - /// - /// - returns: A download file destination closure. - open class func suggestedDownloadDestination( - for directory: FileManager.SearchPathDirectory = .documentDirectory, - in domain: FileManager.SearchPathDomainMask = .userDomainMask) - -> DownloadFileDestination - { - return { temporaryURL, response in - let directoryURLs = FileManager.default.urls(for: directory, in: domain) - - if !directoryURLs.isEmpty { - return (directoryURLs[0].appendingPathComponent(response.suggestedFilename!), []) - } - - return (temporaryURL, []) - } - } -} - -// MARK: - - -/// Specific type of `Request` that manages an underlying `URLSessionUploadTask`. -open class UploadRequest: DataRequest { - - // MARK: Helper Types - - enum Uploadable: TaskConvertible { - case data(Data, URLRequest) - case file(URL, URLRequest) - case stream(InputStream, URLRequest) - - func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask { - do { - let task: URLSessionTask - - switch self { - case let .data(data, urlRequest): - let urlRequest = try urlRequest.adapt(using: adapter) - task = queue.sync { session.uploadTask(with: urlRequest, from: data) } - case let .file(url, urlRequest): - let urlRequest = try urlRequest.adapt(using: adapter) - task = queue.sync { session.uploadTask(with: urlRequest, fromFile: url) } - case let .stream(_, urlRequest): - let urlRequest = try urlRequest.adapt(using: adapter) - task = queue.sync { session.uploadTask(withStreamedRequest: urlRequest) } - } - - return task - } catch { - throw AdaptError(error: error) - } - } - } - - // MARK: Properties - - /// The request sent or to be sent to the server. - open override var request: URLRequest? { - if let request = super.request { return request } - - guard let uploadable = originalTask as? Uploadable else { return nil } - - switch uploadable { - case .data(_, let urlRequest), .file(_, let urlRequest), .stream(_, let urlRequest): - return urlRequest - } - } - - /// The progress of uploading the payload to the server for the upload request. - open var uploadProgress: Progress { return uploadDelegate.uploadProgress } - - var uploadDelegate: UploadTaskDelegate { return delegate as! UploadTaskDelegate } - - // MARK: Upload Progress - - /// Sets a closure to be called periodically during the lifecycle of the `UploadRequest` as data is sent to - /// the server. - /// - /// After the data is sent to the server, the `progress(queue:closure:)` APIs can be used to monitor the progress - /// of data being read from the server. - /// - /// - parameter queue: The dispatch queue to execute the closure on. - /// - parameter closure: The code to be executed periodically as data is sent to the server. - /// - /// - returns: The request. - @discardableResult - open func uploadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self { - uploadDelegate.uploadProgressHandler = (closure, queue) - return self - } -} - -// MARK: - - -#if !os(watchOS) - -/// Specific type of `Request` that manages an underlying `URLSessionStreamTask`. -@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) -open class StreamRequest: Request { - enum Streamable: TaskConvertible { - case stream(hostName: String, port: Int) - case netService(NetService) - - func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask { - let task: URLSessionTask - - switch self { - case let .stream(hostName, port): - task = queue.sync { session.streamTask(withHostName: hostName, port: port) } - case let .netService(netService): - task = queue.sync { session.streamTask(with: netService) } - } - - return task - } - } -} - -#endif diff --git a/Example/Pods/Alamofire/Source/Response.swift b/Example/Pods/Alamofire/Source/Response.swift deleted file mode 100644 index 747a471..0000000 --- a/Example/Pods/Alamofire/Source/Response.swift +++ /dev/null @@ -1,567 +0,0 @@ -// -// Response.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// Used to store all data associated with an non-serialized response of a data or upload request. -public struct DefaultDataResponse { - /// The URL request sent to the server. - public let request: URLRequest? - - /// The server's response to the URL request. - public let response: HTTPURLResponse? - - /// The data returned by the server. - public let data: Data? - - /// The error encountered while executing or validating the request. - public let error: Error? - - /// The timeline of the complete lifecycle of the request. - public let timeline: Timeline - - var _metrics: AnyObject? - - /// Creates a `DefaultDataResponse` instance from the specified parameters. - /// - /// - Parameters: - /// - request: The URL request sent to the server. - /// - response: The server's response to the URL request. - /// - data: The data returned by the server. - /// - error: The error encountered while executing or validating the request. - /// - timeline: The timeline of the complete lifecycle of the request. `Timeline()` by default. - /// - metrics: The task metrics containing the request / response statistics. `nil` by default. - public init( - request: URLRequest?, - response: HTTPURLResponse?, - data: Data?, - error: Error?, - timeline: Timeline = Timeline(), - metrics: AnyObject? = nil) - { - self.request = request - self.response = response - self.data = data - self.error = error - self.timeline = timeline - } -} - -// MARK: - - -/// Used to store all data associated with a serialized response of a data or upload request. -public struct DataResponse { - /// The URL request sent to the server. - public let request: URLRequest? - - /// The server's response to the URL request. - public let response: HTTPURLResponse? - - /// The data returned by the server. - public let data: Data? - - /// The result of response serialization. - public let result: Result - - /// The timeline of the complete lifecycle of the request. - public let timeline: Timeline - - /// Returns the associated value of the result if it is a success, `nil` otherwise. - public var value: Value? { return result.value } - - /// Returns the associated error value if the result if it is a failure, `nil` otherwise. - public var error: Error? { return result.error } - - var _metrics: AnyObject? - - /// Creates a `DataResponse` instance with the specified parameters derived from response serialization. - /// - /// - parameter request: The URL request sent to the server. - /// - parameter response: The server's response to the URL request. - /// - parameter data: The data returned by the server. - /// - parameter result: The result of response serialization. - /// - parameter timeline: The timeline of the complete lifecycle of the `Request`. Defaults to `Timeline()`. - /// - /// - returns: The new `DataResponse` instance. - public init( - request: URLRequest?, - response: HTTPURLResponse?, - data: Data?, - result: Result, - timeline: Timeline = Timeline()) - { - self.request = request - self.response = response - self.data = data - self.result = result - self.timeline = timeline - } -} - -// MARK: - - -extension DataResponse: CustomStringConvertible, CustomDebugStringConvertible { - /// The textual representation used when written to an output stream, which includes whether the result was a - /// success or failure. - public var description: String { - return result.debugDescription - } - - /// The debug textual representation used when written to an output stream, which includes the URL request, the URL - /// response, the server data, the response serialization result and the timeline. - public var debugDescription: String { - var output: [String] = [] - - output.append(request != nil ? "[Request]: \(request!.httpMethod ?? "GET") \(request!)" : "[Request]: nil") - output.append(response != nil ? "[Response]: \(response!)" : "[Response]: nil") - output.append("[Data]: \(data?.count ?? 0) bytes") - output.append("[Result]: \(result.debugDescription)") - output.append("[Timeline]: \(timeline.debugDescription)") - - return output.joined(separator: "\n") - } -} - -// MARK: - - -extension DataResponse { - /// Evaluates the specified closure when the result of this `DataResponse` is a success, passing the unwrapped - /// result value as a parameter. - /// - /// Use the `map` method with a closure that does not throw. For example: - /// - /// let possibleData: DataResponse = ... - /// let possibleInt = possibleData.map { $0.count } - /// - /// - parameter transform: A closure that takes the success value of the instance's result. - /// - /// - returns: A `DataResponse` whose result wraps the value returned by the given closure. If this instance's - /// result is a failure, returns a response wrapping the same failure. - public func map(_ transform: (Value) -> T) -> DataResponse { - var response = DataResponse( - request: request, - response: self.response, - data: data, - result: result.map(transform), - timeline: timeline - ) - - response._metrics = _metrics - - return response - } - - /// Evaluates the given closure when the result of this `DataResponse` is a success, passing the unwrapped result - /// value as a parameter. - /// - /// Use the `flatMap` method with a closure that may throw an error. For example: - /// - /// let possibleData: DataResponse = ... - /// let possibleObject = possibleData.flatMap { - /// try JSONSerialization.jsonObject(with: $0) - /// } - /// - /// - parameter transform: A closure that takes the success value of the instance's result. - /// - /// - returns: A success or failure `DataResponse` depending on the result of the given closure. If this instance's - /// result is a failure, returns the same failure. - public func flatMap(_ transform: (Value) throws -> T) -> DataResponse { - var response = DataResponse( - request: request, - response: self.response, - data: data, - result: result.flatMap(transform), - timeline: timeline - ) - - response._metrics = _metrics - - return response - } - - /// Evaluates the specified closure when the `DataResponse` is a failure, passing the unwrapped error as a parameter. - /// - /// Use the `mapError` function with a closure that does not throw. For example: - /// - /// let possibleData: DataResponse = ... - /// let withMyError = possibleData.mapError { MyError.error($0) } - /// - /// - Parameter transform: A closure that takes the error of the instance. - /// - Returns: A `DataResponse` instance containing the result of the transform. - public func mapError(_ transform: (Error) -> E) -> DataResponse { - var response = DataResponse( - request: request, - response: self.response, - data: data, - result: result.mapError(transform), - timeline: timeline - ) - - response._metrics = _metrics - - return response - } - - /// Evaluates the specified closure when the `DataResponse` is a failure, passing the unwrapped error as a parameter. - /// - /// Use the `flatMapError` function with a closure that may throw an error. For example: - /// - /// let possibleData: DataResponse = ... - /// let possibleObject = possibleData.flatMapError { - /// try someFailableFunction(taking: $0) - /// } - /// - /// - Parameter transform: A throwing closure that takes the error of the instance. - /// - /// - Returns: A `DataResponse` instance containing the result of the transform. - public func flatMapError(_ transform: (Error) throws -> E) -> DataResponse { - var response = DataResponse( - request: request, - response: self.response, - data: data, - result: result.flatMapError(transform), - timeline: timeline - ) - - response._metrics = _metrics - - return response - } -} - -// MARK: - - -/// Used to store all data associated with an non-serialized response of a download request. -public struct DefaultDownloadResponse { - /// The URL request sent to the server. - public let request: URLRequest? - - /// The server's response to the URL request. - public let response: HTTPURLResponse? - - /// The temporary destination URL of the data returned from the server. - public let temporaryURL: URL? - - /// The final destination URL of the data returned from the server if it was moved. - public let destinationURL: URL? - - /// The resume data generated if the request was cancelled. - public let resumeData: Data? - - /// The error encountered while executing or validating the request. - public let error: Error? - - /// The timeline of the complete lifecycle of the request. - public let timeline: Timeline - - var _metrics: AnyObject? - - /// Creates a `DefaultDownloadResponse` instance from the specified parameters. - /// - /// - Parameters: - /// - request: The URL request sent to the server. - /// - response: The server's response to the URL request. - /// - temporaryURL: The temporary destination URL of the data returned from the server. - /// - destinationURL: The final destination URL of the data returned from the server if it was moved. - /// - resumeData: The resume data generated if the request was cancelled. - /// - error: The error encountered while executing or validating the request. - /// - timeline: The timeline of the complete lifecycle of the request. `Timeline()` by default. - /// - metrics: The task metrics containing the request / response statistics. `nil` by default. - public init( - request: URLRequest?, - response: HTTPURLResponse?, - temporaryURL: URL?, - destinationURL: URL?, - resumeData: Data?, - error: Error?, - timeline: Timeline = Timeline(), - metrics: AnyObject? = nil) - { - self.request = request - self.response = response - self.temporaryURL = temporaryURL - self.destinationURL = destinationURL - self.resumeData = resumeData - self.error = error - self.timeline = timeline - } -} - -// MARK: - - -/// Used to store all data associated with a serialized response of a download request. -public struct DownloadResponse { - /// The URL request sent to the server. - public let request: URLRequest? - - /// The server's response to the URL request. - public let response: HTTPURLResponse? - - /// The temporary destination URL of the data returned from the server. - public let temporaryURL: URL? - - /// The final destination URL of the data returned from the server if it was moved. - public let destinationURL: URL? - - /// The resume data generated if the request was cancelled. - public let resumeData: Data? - - /// The result of response serialization. - public let result: Result - - /// The timeline of the complete lifecycle of the request. - public let timeline: Timeline - - /// Returns the associated value of the result if it is a success, `nil` otherwise. - public var value: Value? { return result.value } - - /// Returns the associated error value if the result if it is a failure, `nil` otherwise. - public var error: Error? { return result.error } - - var _metrics: AnyObject? - - /// Creates a `DownloadResponse` instance with the specified parameters derived from response serialization. - /// - /// - parameter request: The URL request sent to the server. - /// - parameter response: The server's response to the URL request. - /// - parameter temporaryURL: The temporary destination URL of the data returned from the server. - /// - parameter destinationURL: The final destination URL of the data returned from the server if it was moved. - /// - parameter resumeData: The resume data generated if the request was cancelled. - /// - parameter result: The result of response serialization. - /// - parameter timeline: The timeline of the complete lifecycle of the `Request`. Defaults to `Timeline()`. - /// - /// - returns: The new `DownloadResponse` instance. - public init( - request: URLRequest?, - response: HTTPURLResponse?, - temporaryURL: URL?, - destinationURL: URL?, - resumeData: Data?, - result: Result, - timeline: Timeline = Timeline()) - { - self.request = request - self.response = response - self.temporaryURL = temporaryURL - self.destinationURL = destinationURL - self.resumeData = resumeData - self.result = result - self.timeline = timeline - } -} - -// MARK: - - -extension DownloadResponse: CustomStringConvertible, CustomDebugStringConvertible { - /// The textual representation used when written to an output stream, which includes whether the result was a - /// success or failure. - public var description: String { - return result.debugDescription - } - - /// The debug textual representation used when written to an output stream, which includes the URL request, the URL - /// response, the temporary and destination URLs, the resume data, the response serialization result and the - /// timeline. - public var debugDescription: String { - var output: [String] = [] - - output.append(request != nil ? "[Request]: \(request!.httpMethod ?? "GET") \(request!)" : "[Request]: nil") - output.append(response != nil ? "[Response]: \(response!)" : "[Response]: nil") - output.append("[TemporaryURL]: \(temporaryURL?.path ?? "nil")") - output.append("[DestinationURL]: \(destinationURL?.path ?? "nil")") - output.append("[ResumeData]: \(resumeData?.count ?? 0) bytes") - output.append("[Result]: \(result.debugDescription)") - output.append("[Timeline]: \(timeline.debugDescription)") - - return output.joined(separator: "\n") - } -} - -// MARK: - - -extension DownloadResponse { - /// Evaluates the given closure when the result of this `DownloadResponse` is a success, passing the unwrapped - /// result value as a parameter. - /// - /// Use the `map` method with a closure that does not throw. For example: - /// - /// let possibleData: DownloadResponse = ... - /// let possibleInt = possibleData.map { $0.count } - /// - /// - parameter transform: A closure that takes the success value of the instance's result. - /// - /// - returns: A `DownloadResponse` whose result wraps the value returned by the given closure. If this instance's - /// result is a failure, returns a response wrapping the same failure. - public func map(_ transform: (Value) -> T) -> DownloadResponse { - var response = DownloadResponse( - request: request, - response: self.response, - temporaryURL: temporaryURL, - destinationURL: destinationURL, - resumeData: resumeData, - result: result.map(transform), - timeline: timeline - ) - - response._metrics = _metrics - - return response - } - - /// Evaluates the given closure when the result of this `DownloadResponse` is a success, passing the unwrapped - /// result value as a parameter. - /// - /// Use the `flatMap` method with a closure that may throw an error. For example: - /// - /// let possibleData: DownloadResponse = ... - /// let possibleObject = possibleData.flatMap { - /// try JSONSerialization.jsonObject(with: $0) - /// } - /// - /// - parameter transform: A closure that takes the success value of the instance's result. - /// - /// - returns: A success or failure `DownloadResponse` depending on the result of the given closure. If this - /// instance's result is a failure, returns the same failure. - public func flatMap(_ transform: (Value) throws -> T) -> DownloadResponse { - var response = DownloadResponse( - request: request, - response: self.response, - temporaryURL: temporaryURL, - destinationURL: destinationURL, - resumeData: resumeData, - result: result.flatMap(transform), - timeline: timeline - ) - - response._metrics = _metrics - - return response - } - - /// Evaluates the specified closure when the `DownloadResponse` is a failure, passing the unwrapped error as a parameter. - /// - /// Use the `mapError` function with a closure that does not throw. For example: - /// - /// let possibleData: DownloadResponse = ... - /// let withMyError = possibleData.mapError { MyError.error($0) } - /// - /// - Parameter transform: A closure that takes the error of the instance. - /// - Returns: A `DownloadResponse` instance containing the result of the transform. - public func mapError(_ transform: (Error) -> E) -> DownloadResponse { - var response = DownloadResponse( - request: request, - response: self.response, - temporaryURL: temporaryURL, - destinationURL: destinationURL, - resumeData: resumeData, - result: result.mapError(transform), - timeline: timeline - ) - - response._metrics = _metrics - - return response - } - - /// Evaluates the specified closure when the `DownloadResponse` is a failure, passing the unwrapped error as a parameter. - /// - /// Use the `flatMapError` function with a closure that may throw an error. For example: - /// - /// let possibleData: DownloadResponse = ... - /// let possibleObject = possibleData.flatMapError { - /// try someFailableFunction(taking: $0) - /// } - /// - /// - Parameter transform: A throwing closure that takes the error of the instance. - /// - /// - Returns: A `DownloadResponse` instance containing the result of the transform. - public func flatMapError(_ transform: (Error) throws -> E) -> DownloadResponse { - var response = DownloadResponse( - request: request, - response: self.response, - temporaryURL: temporaryURL, - destinationURL: destinationURL, - resumeData: resumeData, - result: result.flatMapError(transform), - timeline: timeline - ) - - response._metrics = _metrics - - return response - } -} - -// MARK: - - -protocol Response { - /// The task metrics containing the request / response statistics. - var _metrics: AnyObject? { get set } - mutating func add(_ metrics: AnyObject?) -} - -extension Response { - mutating func add(_ metrics: AnyObject?) { - #if !os(watchOS) - guard #available(iOS 10.0, macOS 10.12, tvOS 10.0, *) else { return } - guard let metrics = metrics as? URLSessionTaskMetrics else { return } - - _metrics = metrics - #endif - } -} - -// MARK: - - -@available(iOS 10.0, macOS 10.12, tvOS 10.0, *) -extension DefaultDataResponse: Response { -#if !os(watchOS) - /// The task metrics containing the request / response statistics. - public var metrics: URLSessionTaskMetrics? { return _metrics as? URLSessionTaskMetrics } -#endif -} - -@available(iOS 10.0, macOS 10.12, tvOS 10.0, *) -extension DataResponse: Response { -#if !os(watchOS) - /// The task metrics containing the request / response statistics. - public var metrics: URLSessionTaskMetrics? { return _metrics as? URLSessionTaskMetrics } -#endif -} - -@available(iOS 10.0, macOS 10.12, tvOS 10.0, *) -extension DefaultDownloadResponse: Response { -#if !os(watchOS) - /// The task metrics containing the request / response statistics. - public var metrics: URLSessionTaskMetrics? { return _metrics as? URLSessionTaskMetrics } -#endif -} - -@available(iOS 10.0, macOS 10.12, tvOS 10.0, *) -extension DownloadResponse: Response { -#if !os(watchOS) - /// The task metrics containing the request / response statistics. - public var metrics: URLSessionTaskMetrics? { return _metrics as? URLSessionTaskMetrics } -#endif -} diff --git a/Example/Pods/Alamofire/Source/ResponseSerialization.swift b/Example/Pods/Alamofire/Source/ResponseSerialization.swift deleted file mode 100644 index 9cc105a..0000000 --- a/Example/Pods/Alamofire/Source/ResponseSerialization.swift +++ /dev/null @@ -1,715 +0,0 @@ -// -// ResponseSerialization.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// The type in which all data response serializers must conform to in order to serialize a response. -public protocol DataResponseSerializerProtocol { - /// The type of serialized object to be created by this `DataResponseSerializerType`. - associatedtype SerializedObject - - /// A closure used by response handlers that takes a request, response, data and error and returns a result. - var serializeResponse: (URLRequest?, HTTPURLResponse?, Data?, Error?) -> Result { get } -} - -// MARK: - - -/// A generic `DataResponseSerializerType` used to serialize a request, response, and data into a serialized object. -public struct DataResponseSerializer: DataResponseSerializerProtocol { - /// The type of serialized object to be created by this `DataResponseSerializer`. - public typealias SerializedObject = Value - - /// A closure used by response handlers that takes a request, response, data and error and returns a result. - public var serializeResponse: (URLRequest?, HTTPURLResponse?, Data?, Error?) -> Result - - /// Initializes the `ResponseSerializer` instance with the given serialize response closure. - /// - /// - parameter serializeResponse: The closure used to serialize the response. - /// - /// - returns: The new generic response serializer instance. - public init(serializeResponse: @escaping (URLRequest?, HTTPURLResponse?, Data?, Error?) -> Result) { - self.serializeResponse = serializeResponse - } -} - -// MARK: - - -/// The type in which all download response serializers must conform to in order to serialize a response. -public protocol DownloadResponseSerializerProtocol { - /// The type of serialized object to be created by this `DownloadResponseSerializerType`. - associatedtype SerializedObject - - /// A closure used by response handlers that takes a request, response, url and error and returns a result. - var serializeResponse: (URLRequest?, HTTPURLResponse?, URL?, Error?) -> Result { get } -} - -// MARK: - - -/// A generic `DownloadResponseSerializerType` used to serialize a request, response, and data into a serialized object. -public struct DownloadResponseSerializer: DownloadResponseSerializerProtocol { - /// The type of serialized object to be created by this `DownloadResponseSerializer`. - public typealias SerializedObject = Value - - /// A closure used by response handlers that takes a request, response, url and error and returns a result. - public var serializeResponse: (URLRequest?, HTTPURLResponse?, URL?, Error?) -> Result - - /// Initializes the `ResponseSerializer` instance with the given serialize response closure. - /// - /// - parameter serializeResponse: The closure used to serialize the response. - /// - /// - returns: The new generic response serializer instance. - public init(serializeResponse: @escaping (URLRequest?, HTTPURLResponse?, URL?, Error?) -> Result) { - self.serializeResponse = serializeResponse - } -} - -// MARK: - Timeline - -extension Request { - var timeline: Timeline { - let requestStartTime = self.startTime ?? CFAbsoluteTimeGetCurrent() - let requestCompletedTime = self.endTime ?? CFAbsoluteTimeGetCurrent() - let initialResponseTime = self.delegate.initialResponseTime ?? requestCompletedTime - - return Timeline( - requestStartTime: requestStartTime, - initialResponseTime: initialResponseTime, - requestCompletedTime: requestCompletedTime, - serializationCompletedTime: CFAbsoluteTimeGetCurrent() - ) - } -} - -// MARK: - Default - -extension DataRequest { - /// Adds a handler to be called once the request has finished. - /// - /// - parameter queue: The queue on which the completion handler is dispatched. - /// - parameter completionHandler: The code to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func response(queue: DispatchQueue? = nil, completionHandler: @escaping (DefaultDataResponse) -> Void) -> Self { - delegate.queue.addOperation { - (queue ?? DispatchQueue.main).async { - var dataResponse = DefaultDataResponse( - request: self.request, - response: self.response, - data: self.delegate.data, - error: self.delegate.error, - timeline: self.timeline - ) - - dataResponse.add(self.delegate.metrics) - - completionHandler(dataResponse) - } - } - - return self - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter queue: The queue on which the completion handler is dispatched. - /// - parameter responseSerializer: The response serializer responsible for serializing the request, response, - /// and data. - /// - parameter completionHandler: The code to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func response( - queue: DispatchQueue? = nil, - responseSerializer: T, - completionHandler: @escaping (DataResponse) -> Void) - -> Self - { - delegate.queue.addOperation { - let result = responseSerializer.serializeResponse( - self.request, - self.response, - self.delegate.data, - self.delegate.error - ) - - var dataResponse = DataResponse( - request: self.request, - response: self.response, - data: self.delegate.data, - result: result, - timeline: self.timeline - ) - - dataResponse.add(self.delegate.metrics) - - (queue ?? DispatchQueue.main).async { completionHandler(dataResponse) } - } - - return self - } -} - -extension DownloadRequest { - /// Adds a handler to be called once the request has finished. - /// - /// - parameter queue: The queue on which the completion handler is dispatched. - /// - parameter completionHandler: The code to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func response( - queue: DispatchQueue? = nil, - completionHandler: @escaping (DefaultDownloadResponse) -> Void) - -> Self - { - delegate.queue.addOperation { - (queue ?? DispatchQueue.main).async { - var downloadResponse = DefaultDownloadResponse( - request: self.request, - response: self.response, - temporaryURL: self.downloadDelegate.temporaryURL, - destinationURL: self.downloadDelegate.destinationURL, - resumeData: self.downloadDelegate.resumeData, - error: self.downloadDelegate.error, - timeline: self.timeline - ) - - downloadResponse.add(self.delegate.metrics) - - completionHandler(downloadResponse) - } - } - - return self - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter queue: The queue on which the completion handler is dispatched. - /// - parameter responseSerializer: The response serializer responsible for serializing the request, response, - /// and data contained in the destination url. - /// - parameter completionHandler: The code to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func response( - queue: DispatchQueue? = nil, - responseSerializer: T, - completionHandler: @escaping (DownloadResponse) -> Void) - -> Self - { - delegate.queue.addOperation { - let result = responseSerializer.serializeResponse( - self.request, - self.response, - self.downloadDelegate.fileURL, - self.downloadDelegate.error - ) - - var downloadResponse = DownloadResponse( - request: self.request, - response: self.response, - temporaryURL: self.downloadDelegate.temporaryURL, - destinationURL: self.downloadDelegate.destinationURL, - resumeData: self.downloadDelegate.resumeData, - result: result, - timeline: self.timeline - ) - - downloadResponse.add(self.delegate.metrics) - - (queue ?? DispatchQueue.main).async { completionHandler(downloadResponse) } - } - - return self - } -} - -// MARK: - Data - -extension Request { - /// Returns a result data type that contains the response data as-is. - /// - /// - parameter response: The response from the server. - /// - parameter data: The data returned from the server. - /// - parameter error: The error already encountered if it exists. - /// - /// - returns: The result data type. - public static func serializeResponseData(response: HTTPURLResponse?, data: Data?, error: Error?) -> Result { - guard error == nil else { return .failure(error!) } - - if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(Data()) } - - guard let validData = data else { - return .failure(AFError.responseSerializationFailed(reason: .inputDataNil)) - } - - return .success(validData) - } -} - -extension DataRequest { - /// Creates a response serializer that returns the associated data as-is. - /// - /// - returns: A data response serializer. - public static func dataResponseSerializer() -> DataResponseSerializer { - return DataResponseSerializer { _, response, data, error in - return Request.serializeResponseData(response: response, data: data, error: error) - } - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter completionHandler: The code to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func responseData( - queue: DispatchQueue? = nil, - completionHandler: @escaping (DataResponse) -> Void) - -> Self - { - return response( - queue: queue, - responseSerializer: DataRequest.dataResponseSerializer(), - completionHandler: completionHandler - ) - } -} - -extension DownloadRequest { - /// Creates a response serializer that returns the associated data as-is. - /// - /// - returns: A data response serializer. - public static func dataResponseSerializer() -> DownloadResponseSerializer { - return DownloadResponseSerializer { _, response, fileURL, error in - guard error == nil else { return .failure(error!) } - - guard let fileURL = fileURL else { - return .failure(AFError.responseSerializationFailed(reason: .inputFileNil)) - } - - do { - let data = try Data(contentsOf: fileURL) - return Request.serializeResponseData(response: response, data: data, error: error) - } catch { - return .failure(AFError.responseSerializationFailed(reason: .inputFileReadFailed(at: fileURL))) - } - } - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter completionHandler: The code to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func responseData( - queue: DispatchQueue? = nil, - completionHandler: @escaping (DownloadResponse) -> Void) - -> Self - { - return response( - queue: queue, - responseSerializer: DownloadRequest.dataResponseSerializer(), - completionHandler: completionHandler - ) - } -} - -// MARK: - String - -extension Request { - /// Returns a result string type initialized from the response data with the specified string encoding. - /// - /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the server - /// response, falling back to the default HTTP default character set, ISO-8859-1. - /// - parameter response: The response from the server. - /// - parameter data: The data returned from the server. - /// - parameter error: The error already encountered if it exists. - /// - /// - returns: The result data type. - public static func serializeResponseString( - encoding: String.Encoding?, - response: HTTPURLResponse?, - data: Data?, - error: Error?) - -> Result - { - guard error == nil else { return .failure(error!) } - - if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success("") } - - guard let validData = data else { - return .failure(AFError.responseSerializationFailed(reason: .inputDataNil)) - } - - var convertedEncoding = encoding - - if let encodingName = response?.textEncodingName as CFString?, convertedEncoding == nil { - convertedEncoding = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding( - CFStringConvertIANACharSetNameToEncoding(encodingName)) - ) - } - - let actualEncoding = convertedEncoding ?? .isoLatin1 - - if let string = String(data: validData, encoding: actualEncoding) { - return .success(string) - } else { - return .failure(AFError.responseSerializationFailed(reason: .stringSerializationFailed(encoding: actualEncoding))) - } - } -} - -extension DataRequest { - /// Creates a response serializer that returns a result string type initialized from the response data with - /// the specified string encoding. - /// - /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the server - /// response, falling back to the default HTTP default character set, ISO-8859-1. - /// - /// - returns: A string response serializer. - public static func stringResponseSerializer(encoding: String.Encoding? = nil) -> DataResponseSerializer { - return DataResponseSerializer { _, response, data, error in - return Request.serializeResponseString(encoding: encoding, response: response, data: data, error: error) - } - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the - /// server response, falling back to the default HTTP default character set, - /// ISO-8859-1. - /// - parameter completionHandler: A closure to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func responseString( - queue: DispatchQueue? = nil, - encoding: String.Encoding? = nil, - completionHandler: @escaping (DataResponse) -> Void) - -> Self - { - return response( - queue: queue, - responseSerializer: DataRequest.stringResponseSerializer(encoding: encoding), - completionHandler: completionHandler - ) - } -} - -extension DownloadRequest { - /// Creates a response serializer that returns a result string type initialized from the response data with - /// the specified string encoding. - /// - /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the server - /// response, falling back to the default HTTP default character set, ISO-8859-1. - /// - /// - returns: A string response serializer. - public static func stringResponseSerializer(encoding: String.Encoding? = nil) -> DownloadResponseSerializer { - return DownloadResponseSerializer { _, response, fileURL, error in - guard error == nil else { return .failure(error!) } - - guard let fileURL = fileURL else { - return .failure(AFError.responseSerializationFailed(reason: .inputFileNil)) - } - - do { - let data = try Data(contentsOf: fileURL) - return Request.serializeResponseString(encoding: encoding, response: response, data: data, error: error) - } catch { - return .failure(AFError.responseSerializationFailed(reason: .inputFileReadFailed(at: fileURL))) - } - } - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the - /// server response, falling back to the default HTTP default character set, - /// ISO-8859-1. - /// - parameter completionHandler: A closure to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func responseString( - queue: DispatchQueue? = nil, - encoding: String.Encoding? = nil, - completionHandler: @escaping (DownloadResponse) -> Void) - -> Self - { - return response( - queue: queue, - responseSerializer: DownloadRequest.stringResponseSerializer(encoding: encoding), - completionHandler: completionHandler - ) - } -} - -// MARK: - JSON - -extension Request { - /// Returns a JSON object contained in a result type constructed from the response data using `JSONSerialization` - /// with the specified reading options. - /// - /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. - /// - parameter response: The response from the server. - /// - parameter data: The data returned from the server. - /// - parameter error: The error already encountered if it exists. - /// - /// - returns: The result data type. - public static func serializeResponseJSON( - options: JSONSerialization.ReadingOptions, - response: HTTPURLResponse?, - data: Data?, - error: Error?) - -> Result - { - guard error == nil else { return .failure(error!) } - - if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(NSNull()) } - - guard let validData = data, validData.count > 0 else { - return .failure(AFError.responseSerializationFailed(reason: .inputDataNilOrZeroLength)) - } - - do { - let json = try JSONSerialization.jsonObject(with: validData, options: options) - return .success(json) - } catch { - return .failure(AFError.responseSerializationFailed(reason: .jsonSerializationFailed(error: error))) - } - } -} - -extension DataRequest { - /// Creates a response serializer that returns a JSON object result type constructed from the response data using - /// `JSONSerialization` with the specified reading options. - /// - /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. - /// - /// - returns: A JSON object response serializer. - public static func jsonResponseSerializer( - options: JSONSerialization.ReadingOptions = .allowFragments) - -> DataResponseSerializer - { - return DataResponseSerializer { _, response, data, error in - return Request.serializeResponseJSON(options: options, response: response, data: data, error: error) - } - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. - /// - parameter completionHandler: A closure to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func responseJSON( - queue: DispatchQueue? = nil, - options: JSONSerialization.ReadingOptions = .allowFragments, - completionHandler: @escaping (DataResponse) -> Void) - -> Self - { - return response( - queue: queue, - responseSerializer: DataRequest.jsonResponseSerializer(options: options), - completionHandler: completionHandler - ) - } -} - -extension DownloadRequest { - /// Creates a response serializer that returns a JSON object result type constructed from the response data using - /// `JSONSerialization` with the specified reading options. - /// - /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. - /// - /// - returns: A JSON object response serializer. - public static func jsonResponseSerializer( - options: JSONSerialization.ReadingOptions = .allowFragments) - -> DownloadResponseSerializer - { - return DownloadResponseSerializer { _, response, fileURL, error in - guard error == nil else { return .failure(error!) } - - guard let fileURL = fileURL else { - return .failure(AFError.responseSerializationFailed(reason: .inputFileNil)) - } - - do { - let data = try Data(contentsOf: fileURL) - return Request.serializeResponseJSON(options: options, response: response, data: data, error: error) - } catch { - return .failure(AFError.responseSerializationFailed(reason: .inputFileReadFailed(at: fileURL))) - } - } - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. - /// - parameter completionHandler: A closure to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func responseJSON( - queue: DispatchQueue? = nil, - options: JSONSerialization.ReadingOptions = .allowFragments, - completionHandler: @escaping (DownloadResponse) -> Void) - -> Self - { - return response( - queue: queue, - responseSerializer: DownloadRequest.jsonResponseSerializer(options: options), - completionHandler: completionHandler - ) - } -} - -// MARK: - Property List - -extension Request { - /// Returns a plist object contained in a result type constructed from the response data using - /// `PropertyListSerialization` with the specified reading options. - /// - /// - parameter options: The property list reading options. Defaults to `[]`. - /// - parameter response: The response from the server. - /// - parameter data: The data returned from the server. - /// - parameter error: The error already encountered if it exists. - /// - /// - returns: The result data type. - public static func serializeResponsePropertyList( - options: PropertyListSerialization.ReadOptions, - response: HTTPURLResponse?, - data: Data?, - error: Error?) - -> Result - { - guard error == nil else { return .failure(error!) } - - if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(NSNull()) } - - guard let validData = data, validData.count > 0 else { - return .failure(AFError.responseSerializationFailed(reason: .inputDataNilOrZeroLength)) - } - - do { - let plist = try PropertyListSerialization.propertyList(from: validData, options: options, format: nil) - return .success(plist) - } catch { - return .failure(AFError.responseSerializationFailed(reason: .propertyListSerializationFailed(error: error))) - } - } -} - -extension DataRequest { - /// Creates a response serializer that returns an object constructed from the response data using - /// `PropertyListSerialization` with the specified reading options. - /// - /// - parameter options: The property list reading options. Defaults to `[]`. - /// - /// - returns: A property list object response serializer. - public static func propertyListResponseSerializer( - options: PropertyListSerialization.ReadOptions = []) - -> DataResponseSerializer - { - return DataResponseSerializer { _, response, data, error in - return Request.serializeResponsePropertyList(options: options, response: response, data: data, error: error) - } - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter options: The property list reading options. Defaults to `[]`. - /// - parameter completionHandler: A closure to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func responsePropertyList( - queue: DispatchQueue? = nil, - options: PropertyListSerialization.ReadOptions = [], - completionHandler: @escaping (DataResponse) -> Void) - -> Self - { - return response( - queue: queue, - responseSerializer: DataRequest.propertyListResponseSerializer(options: options), - completionHandler: completionHandler - ) - } -} - -extension DownloadRequest { - /// Creates a response serializer that returns an object constructed from the response data using - /// `PropertyListSerialization` with the specified reading options. - /// - /// - parameter options: The property list reading options. Defaults to `[]`. - /// - /// - returns: A property list object response serializer. - public static func propertyListResponseSerializer( - options: PropertyListSerialization.ReadOptions = []) - -> DownloadResponseSerializer - { - return DownloadResponseSerializer { _, response, fileURL, error in - guard error == nil else { return .failure(error!) } - - guard let fileURL = fileURL else { - return .failure(AFError.responseSerializationFailed(reason: .inputFileNil)) - } - - do { - let data = try Data(contentsOf: fileURL) - return Request.serializeResponsePropertyList(options: options, response: response, data: data, error: error) - } catch { - return .failure(AFError.responseSerializationFailed(reason: .inputFileReadFailed(at: fileURL))) - } - } - } - - /// Adds a handler to be called once the request has finished. - /// - /// - parameter options: The property list reading options. Defaults to `[]`. - /// - parameter completionHandler: A closure to be executed once the request has finished. - /// - /// - returns: The request. - @discardableResult - public func responsePropertyList( - queue: DispatchQueue? = nil, - options: PropertyListSerialization.ReadOptions = [], - completionHandler: @escaping (DownloadResponse) -> Void) - -> Self - { - return response( - queue: queue, - responseSerializer: DownloadRequest.propertyListResponseSerializer(options: options), - completionHandler: completionHandler - ) - } -} - -/// A set of HTTP response status code that do not contain response data. -private let emptyDataStatusCodes: Set = [204, 205] diff --git a/Example/Pods/Alamofire/Source/Result.swift b/Example/Pods/Alamofire/Source/Result.swift deleted file mode 100644 index e092808..0000000 --- a/Example/Pods/Alamofire/Source/Result.swift +++ /dev/null @@ -1,300 +0,0 @@ -// -// Result.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// Used to represent whether a request was successful or encountered an error. -/// -/// - success: The request and all post processing operations were successful resulting in the serialization of the -/// provided associated value. -/// -/// - failure: The request encountered an error resulting in a failure. The associated values are the original data -/// provided by the server as well as the error that caused the failure. -public enum Result { - case success(Value) - case failure(Error) - - /// Returns `true` if the result is a success, `false` otherwise. - public var isSuccess: Bool { - switch self { - case .success: - return true - case .failure: - return false - } - } - - /// Returns `true` if the result is a failure, `false` otherwise. - public var isFailure: Bool { - return !isSuccess - } - - /// Returns the associated value if the result is a success, `nil` otherwise. - public var value: Value? { - switch self { - case .success(let value): - return value - case .failure: - return nil - } - } - - /// Returns the associated error value if the result is a failure, `nil` otherwise. - public var error: Error? { - switch self { - case .success: - return nil - case .failure(let error): - return error - } - } -} - -// MARK: - CustomStringConvertible - -extension Result: CustomStringConvertible { - /// The textual representation used when written to an output stream, which includes whether the result was a - /// success or failure. - public var description: String { - switch self { - case .success: - return "SUCCESS" - case .failure: - return "FAILURE" - } - } -} - -// MARK: - CustomDebugStringConvertible - -extension Result: CustomDebugStringConvertible { - /// The debug textual representation used when written to an output stream, which includes whether the result was a - /// success or failure in addition to the value or error. - public var debugDescription: String { - switch self { - case .success(let value): - return "SUCCESS: \(value)" - case .failure(let error): - return "FAILURE: \(error)" - } - } -} - -// MARK: - Functional APIs - -extension Result { - /// Creates a `Result` instance from the result of a closure. - /// - /// A failure result is created when the closure throws, and a success result is created when the closure - /// succeeds without throwing an error. - /// - /// func someString() throws -> String { ... } - /// - /// let result = Result(value: { - /// return try someString() - /// }) - /// - /// // The type of result is Result - /// - /// The trailing closure syntax is also supported: - /// - /// let result = Result { try someString() } - /// - /// - parameter value: The closure to execute and create the result for. - public init(value: () throws -> Value) { - do { - self = try .success(value()) - } catch { - self = .failure(error) - } - } - - /// Returns the success value, or throws the failure error. - /// - /// let possibleString: Result = .success("success") - /// try print(possibleString.unwrap()) - /// // Prints "success" - /// - /// let noString: Result = .failure(error) - /// try print(noString.unwrap()) - /// // Throws error - public func unwrap() throws -> Value { - switch self { - case .success(let value): - return value - case .failure(let error): - throw error - } - } - - /// Evaluates the specified closure when the `Result` is a success, passing the unwrapped value as a parameter. - /// - /// Use the `map` method with a closure that does not throw. For example: - /// - /// let possibleData: Result = .success(Data()) - /// let possibleInt = possibleData.map { $0.count } - /// try print(possibleInt.unwrap()) - /// // Prints "0" - /// - /// let noData: Result = .failure(error) - /// let noInt = noData.map { $0.count } - /// try print(noInt.unwrap()) - /// // Throws error - /// - /// - parameter transform: A closure that takes the success value of the `Result` instance. - /// - /// - returns: A `Result` containing the result of the given closure. If this instance is a failure, returns the - /// same failure. - public func map(_ transform: (Value) -> T) -> Result { - switch self { - case .success(let value): - return .success(transform(value)) - case .failure(let error): - return .failure(error) - } - } - - /// Evaluates the specified closure when the `Result` is a success, passing the unwrapped value as a parameter. - /// - /// Use the `flatMap` method with a closure that may throw an error. For example: - /// - /// let possibleData: Result = .success(Data(...)) - /// let possibleObject = possibleData.flatMap { - /// try JSONSerialization.jsonObject(with: $0) - /// } - /// - /// - parameter transform: A closure that takes the success value of the instance. - /// - /// - returns: A `Result` containing the result of the given closure. If this instance is a failure, returns the - /// same failure. - public func flatMap(_ transform: (Value) throws -> T) -> Result { - switch self { - case .success(let value): - do { - return try .success(transform(value)) - } catch { - return .failure(error) - } - case .failure(let error): - return .failure(error) - } - } - - /// Evaluates the specified closure when the `Result` is a failure, passing the unwrapped error as a parameter. - /// - /// Use the `mapError` function with a closure that does not throw. For example: - /// - /// let possibleData: Result = .failure(someError) - /// let withMyError: Result = possibleData.mapError { MyError.error($0) } - /// - /// - Parameter transform: A closure that takes the error of the instance. - /// - Returns: A `Result` instance containing the result of the transform. If this instance is a success, returns - /// the same instance. - public func mapError(_ transform: (Error) -> T) -> Result { - switch self { - case .failure(let error): - return .failure(transform(error)) - case .success: - return self - } - } - - /// Evaluates the specified closure when the `Result` is a failure, passing the unwrapped error as a parameter. - /// - /// Use the `flatMapError` function with a closure that may throw an error. For example: - /// - /// let possibleData: Result = .success(Data(...)) - /// let possibleObject = possibleData.flatMapError { - /// try someFailableFunction(taking: $0) - /// } - /// - /// - Parameter transform: A throwing closure that takes the error of the instance. - /// - /// - Returns: A `Result` instance containing the result of the transform. If this instance is a success, returns - /// the same instance. - public func flatMapError(_ transform: (Error) throws -> T) -> Result { - switch self { - case .failure(let error): - do { - return try .failure(transform(error)) - } catch { - return .failure(error) - } - case .success: - return self - } - } - - /// Evaluates the specified closure when the `Result` is a success, passing the unwrapped value as a parameter. - /// - /// Use the `withValue` function to evaluate the passed closure without modifying the `Result` instance. - /// - /// - Parameter closure: A closure that takes the success value of this instance. - /// - Returns: This `Result` instance, unmodified. - @discardableResult - public func withValue(_ closure: (Value) throws -> Void) rethrows -> Result { - if case let .success(value) = self { try closure(value) } - - return self - } - - /// Evaluates the specified closure when the `Result` is a failure, passing the unwrapped error as a parameter. - /// - /// Use the `withError` function to evaluate the passed closure without modifying the `Result` instance. - /// - /// - Parameter closure: A closure that takes the success value of this instance. - /// - Returns: This `Result` instance, unmodified. - @discardableResult - public func withError(_ closure: (Error) throws -> Void) rethrows -> Result { - if case let .failure(error) = self { try closure(error) } - - return self - } - - /// Evaluates the specified closure when the `Result` is a success. - /// - /// Use the `ifSuccess` function to evaluate the passed closure without modifying the `Result` instance. - /// - /// - Parameter closure: A `Void` closure. - /// - Returns: This `Result` instance, unmodified. - @discardableResult - public func ifSuccess(_ closure: () throws -> Void) rethrows -> Result { - if isSuccess { try closure() } - - return self - } - - /// Evaluates the specified closure when the `Result` is a failure. - /// - /// Use the `ifFailure` function to evaluate the passed closure without modifying the `Result` instance. - /// - /// - Parameter closure: A `Void` closure. - /// - Returns: This `Result` instance, unmodified. - @discardableResult - public func ifFailure(_ closure: () throws -> Void) rethrows -> Result { - if isFailure { try closure() } - - return self - } -} diff --git a/Example/Pods/Alamofire/Source/ServerTrustPolicy.swift b/Example/Pods/Alamofire/Source/ServerTrustPolicy.swift deleted file mode 100644 index dea099e..0000000 --- a/Example/Pods/Alamofire/Source/ServerTrustPolicy.swift +++ /dev/null @@ -1,307 +0,0 @@ -// -// ServerTrustPolicy.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// Responsible for managing the mapping of `ServerTrustPolicy` objects to a given host. -open class ServerTrustPolicyManager { - /// The dictionary of policies mapped to a particular host. - public let policies: [String: ServerTrustPolicy] - - /// Initializes the `ServerTrustPolicyManager` instance with the given policies. - /// - /// Since different servers and web services can have different leaf certificates, intermediate and even root - /// certficates, it is important to have the flexibility to specify evaluation policies on a per host basis. This - /// allows for scenarios such as using default evaluation for host1, certificate pinning for host2, public key - /// pinning for host3 and disabling evaluation for host4. - /// - /// - parameter policies: A dictionary of all policies mapped to a particular host. - /// - /// - returns: The new `ServerTrustPolicyManager` instance. - public init(policies: [String: ServerTrustPolicy]) { - self.policies = policies - } - - /// Returns the `ServerTrustPolicy` for the given host if applicable. - /// - /// By default, this method will return the policy that perfectly matches the given host. Subclasses could override - /// this method and implement more complex mapping implementations such as wildcards. - /// - /// - parameter host: The host to use when searching for a matching policy. - /// - /// - returns: The server trust policy for the given host if found. - open func serverTrustPolicy(forHost host: String) -> ServerTrustPolicy? { - return policies[host] - } -} - -// MARK: - - -extension URLSession { - private struct AssociatedKeys { - static var managerKey = "URLSession.ServerTrustPolicyManager" - } - - var serverTrustPolicyManager: ServerTrustPolicyManager? { - get { - return objc_getAssociatedObject(self, &AssociatedKeys.managerKey) as? ServerTrustPolicyManager - } - set (manager) { - objc_setAssociatedObject(self, &AssociatedKeys.managerKey, manager, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) - } - } -} - -// MARK: - ServerTrustPolicy - -/// The `ServerTrustPolicy` evaluates the server trust generally provided by an `NSURLAuthenticationChallenge` when -/// connecting to a server over a secure HTTPS connection. The policy configuration then evaluates the server trust -/// with a given set of criteria to determine whether the server trust is valid and the connection should be made. -/// -/// Using pinned certificates or public keys for evaluation helps prevent man-in-the-middle (MITM) attacks and other -/// vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged -/// to route all communication over an HTTPS connection with pinning enabled. -/// -/// - performDefaultEvaluation: Uses the default server trust evaluation while allowing you to control whether to -/// validate the host provided by the challenge. Applications are encouraged to always -/// validate the host in production environments to guarantee the validity of the server's -/// certificate chain. -/// -/// - performRevokedEvaluation: Uses the default and revoked server trust evaluations allowing you to control whether to -/// validate the host provided by the challenge as well as specify the revocation flags for -/// testing for revoked certificates. Apple platforms did not start testing for revoked -/// certificates automatically until iOS 10.1, macOS 10.12 and tvOS 10.1 which is -/// demonstrated in our TLS tests. Applications are encouraged to always validate the host -/// in production environments to guarantee the validity of the server's certificate chain. -/// -/// - pinCertificates: Uses the pinned certificates to validate the server trust. The server trust is -/// considered valid if one of the pinned certificates match one of the server certificates. -/// By validating both the certificate chain and host, certificate pinning provides a very -/// secure form of server trust validation mitigating most, if not all, MITM attacks. -/// Applications are encouraged to always validate the host and require a valid certificate -/// chain in production environments. -/// -/// - pinPublicKeys: Uses the pinned public keys to validate the server trust. The server trust is considered -/// valid if one of the pinned public keys match one of the server certificate public keys. -/// By validating both the certificate chain and host, public key pinning provides a very -/// secure form of server trust validation mitigating most, if not all, MITM attacks. -/// Applications are encouraged to always validate the host and require a valid certificate -/// chain in production environments. -/// -/// - disableEvaluation: Disables all evaluation which in turn will always consider any server trust as valid. -/// -/// - customEvaluation: Uses the associated closure to evaluate the validity of the server trust. -public enum ServerTrustPolicy { - case performDefaultEvaluation(validateHost: Bool) - case performRevokedEvaluation(validateHost: Bool, revocationFlags: CFOptionFlags) - case pinCertificates(certificates: [SecCertificate], validateCertificateChain: Bool, validateHost: Bool) - case pinPublicKeys(publicKeys: [SecKey], validateCertificateChain: Bool, validateHost: Bool) - case disableEvaluation - case customEvaluation((_ serverTrust: SecTrust, _ host: String) -> Bool) - - // MARK: - Bundle Location - - /// Returns all certificates within the given bundle with a `.cer` file extension. - /// - /// - parameter bundle: The bundle to search for all `.cer` files. - /// - /// - returns: All certificates within the given bundle. - public static func certificates(in bundle: Bundle = Bundle.main) -> [SecCertificate] { - var certificates: [SecCertificate] = [] - - let paths = Set([".cer", ".CER", ".crt", ".CRT", ".der", ".DER"].map { fileExtension in - bundle.paths(forResourcesOfType: fileExtension, inDirectory: nil) - }.joined()) - - for path in paths { - if - let certificateData = try? Data(contentsOf: URL(fileURLWithPath: path)) as CFData, - let certificate = SecCertificateCreateWithData(nil, certificateData) - { - certificates.append(certificate) - } - } - - return certificates - } - - /// Returns all public keys within the given bundle with a `.cer` file extension. - /// - /// - parameter bundle: The bundle to search for all `*.cer` files. - /// - /// - returns: All public keys within the given bundle. - public static func publicKeys(in bundle: Bundle = Bundle.main) -> [SecKey] { - var publicKeys: [SecKey] = [] - - for certificate in certificates(in: bundle) { - if let publicKey = publicKey(for: certificate) { - publicKeys.append(publicKey) - } - } - - return publicKeys - } - - // MARK: - Evaluation - - /// Evaluates whether the server trust is valid for the given host. - /// - /// - parameter serverTrust: The server trust to evaluate. - /// - parameter host: The host of the challenge protection space. - /// - /// - returns: Whether the server trust is valid. - public func evaluate(_ serverTrust: SecTrust, forHost host: String) -> Bool { - var serverTrustIsValid = false - - switch self { - case let .performDefaultEvaluation(validateHost): - let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) - SecTrustSetPolicies(serverTrust, policy) - - serverTrustIsValid = trustIsValid(serverTrust) - case let .performRevokedEvaluation(validateHost, revocationFlags): - let defaultPolicy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) - let revokedPolicy = SecPolicyCreateRevocation(revocationFlags) - SecTrustSetPolicies(serverTrust, [defaultPolicy, revokedPolicy] as CFTypeRef) - - serverTrustIsValid = trustIsValid(serverTrust) - case let .pinCertificates(pinnedCertificates, validateCertificateChain, validateHost): - if validateCertificateChain { - let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) - SecTrustSetPolicies(serverTrust, policy) - - SecTrustSetAnchorCertificates(serverTrust, pinnedCertificates as CFArray) - SecTrustSetAnchorCertificatesOnly(serverTrust, true) - - serverTrustIsValid = trustIsValid(serverTrust) - } else { - let serverCertificatesDataArray = certificateData(for: serverTrust) - let pinnedCertificatesDataArray = certificateData(for: pinnedCertificates) - - outerLoop: for serverCertificateData in serverCertificatesDataArray { - for pinnedCertificateData in pinnedCertificatesDataArray { - if serverCertificateData == pinnedCertificateData { - serverTrustIsValid = true - break outerLoop - } - } - } - } - case let .pinPublicKeys(pinnedPublicKeys, validateCertificateChain, validateHost): - var certificateChainEvaluationPassed = true - - if validateCertificateChain { - let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) - SecTrustSetPolicies(serverTrust, policy) - - certificateChainEvaluationPassed = trustIsValid(serverTrust) - } - - if certificateChainEvaluationPassed { - outerLoop: for serverPublicKey in ServerTrustPolicy.publicKeys(for: serverTrust) as [AnyObject] { - for pinnedPublicKey in pinnedPublicKeys as [AnyObject] { - if serverPublicKey.isEqual(pinnedPublicKey) { - serverTrustIsValid = true - break outerLoop - } - } - } - } - case .disableEvaluation: - serverTrustIsValid = true - case let .customEvaluation(closure): - serverTrustIsValid = closure(serverTrust, host) - } - - return serverTrustIsValid - } - - // MARK: - Private - Trust Validation - - private func trustIsValid(_ trust: SecTrust) -> Bool { - var isValid = false - - var result = SecTrustResultType.invalid - let status = SecTrustEvaluate(trust, &result) - - if status == errSecSuccess { - let unspecified = SecTrustResultType.unspecified - let proceed = SecTrustResultType.proceed - - - isValid = result == unspecified || result == proceed - } - - return isValid - } - - // MARK: - Private - Certificate Data - - private func certificateData(for trust: SecTrust) -> [Data] { - var certificates: [SecCertificate] = [] - - for index in 0.. [Data] { - return certificates.map { SecCertificateCopyData($0) as Data } - } - - // MARK: - Private - Public Key Extraction - - private static func publicKeys(for trust: SecTrust) -> [SecKey] { - var publicKeys: [SecKey] = [] - - for index in 0.. SecKey? { - var publicKey: SecKey? - - let policy = SecPolicyCreateBasicX509() - var trust: SecTrust? - let trustCreationStatus = SecTrustCreateWithCertificates(certificate, policy, &trust) - - if let trust = trust, trustCreationStatus == errSecSuccess { - publicKey = SecTrustCopyPublicKey(trust) - } - - return publicKey - } -} diff --git a/Example/Pods/Alamofire/Source/SessionDelegate.swift b/Example/Pods/Alamofire/Source/SessionDelegate.swift deleted file mode 100644 index 4964f1e..0000000 --- a/Example/Pods/Alamofire/Source/SessionDelegate.swift +++ /dev/null @@ -1,725 +0,0 @@ -// -// SessionDelegate.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// Responsible for handling all delegate callbacks for the underlying session. -open class SessionDelegate: NSObject { - - // MARK: URLSessionDelegate Overrides - - /// Overrides default behavior for URLSessionDelegate method `urlSession(_:didBecomeInvalidWithError:)`. - open var sessionDidBecomeInvalidWithError: ((URLSession, Error?) -> Void)? - - /// Overrides default behavior for URLSessionDelegate method `urlSession(_:didReceive:completionHandler:)`. - open var sessionDidReceiveChallenge: ((URLSession, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))? - - /// Overrides all behavior for URLSessionDelegate method `urlSession(_:didReceive:completionHandler:)` and requires the caller to call the `completionHandler`. - open var sessionDidReceiveChallengeWithCompletion: ((URLSession, URLAuthenticationChallenge, @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> Void)? - - /// Overrides default behavior for URLSessionDelegate method `urlSessionDidFinishEvents(forBackgroundURLSession:)`. - open var sessionDidFinishEventsForBackgroundURLSession: ((URLSession) -> Void)? - - // MARK: URLSessionTaskDelegate Overrides - - /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)`. - open var taskWillPerformHTTPRedirection: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest) -> URLRequest?)? - - /// Overrides all behavior for URLSessionTaskDelegate method `urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)` and - /// requires the caller to call the `completionHandler`. - open var taskWillPerformHTTPRedirectionWithCompletion: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest, @escaping (URLRequest?) -> Void) -> Void)? - - /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:didReceive:completionHandler:)`. - open var taskDidReceiveChallenge: ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))? - - /// Overrides all behavior for URLSessionTaskDelegate method `urlSession(_:task:didReceive:completionHandler:)` and - /// requires the caller to call the `completionHandler`. - open var taskDidReceiveChallengeWithCompletion: ((URLSession, URLSessionTask, URLAuthenticationChallenge, @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> Void)? - - /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:needNewBodyStream:)`. - open var taskNeedNewBodyStream: ((URLSession, URLSessionTask) -> InputStream?)? - - /// Overrides all behavior for URLSessionTaskDelegate method `urlSession(_:task:needNewBodyStream:)` and - /// requires the caller to call the `completionHandler`. - open var taskNeedNewBodyStreamWithCompletion: ((URLSession, URLSessionTask, @escaping (InputStream?) -> Void) -> Void)? - - /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)`. - open var taskDidSendBodyData: ((URLSession, URLSessionTask, Int64, Int64, Int64) -> Void)? - - /// Overrides default behavior for URLSessionTaskDelegate method `urlSession(_:task:didCompleteWithError:)`. - open var taskDidComplete: ((URLSession, URLSessionTask, Error?) -> Void)? - - // MARK: URLSessionDataDelegate Overrides - - /// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:didReceive:completionHandler:)`. - open var dataTaskDidReceiveResponse: ((URLSession, URLSessionDataTask, URLResponse) -> URLSession.ResponseDisposition)? - - /// Overrides all behavior for URLSessionDataDelegate method `urlSession(_:dataTask:didReceive:completionHandler:)` and - /// requires caller to call the `completionHandler`. - open var dataTaskDidReceiveResponseWithCompletion: ((URLSession, URLSessionDataTask, URLResponse, @escaping (URLSession.ResponseDisposition) -> Void) -> Void)? - - /// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:didBecome:)`. - open var dataTaskDidBecomeDownloadTask: ((URLSession, URLSessionDataTask, URLSessionDownloadTask) -> Void)? - - /// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:didReceive:)`. - open var dataTaskDidReceiveData: ((URLSession, URLSessionDataTask, Data) -> Void)? - - /// Overrides default behavior for URLSessionDataDelegate method `urlSession(_:dataTask:willCacheResponse:completionHandler:)`. - open var dataTaskWillCacheResponse: ((URLSession, URLSessionDataTask, CachedURLResponse) -> CachedURLResponse?)? - - /// Overrides all behavior for URLSessionDataDelegate method `urlSession(_:dataTask:willCacheResponse:completionHandler:)` and - /// requires caller to call the `completionHandler`. - open var dataTaskWillCacheResponseWithCompletion: ((URLSession, URLSessionDataTask, CachedURLResponse, @escaping (CachedURLResponse?) -> Void) -> Void)? - - // MARK: URLSessionDownloadDelegate Overrides - - /// Overrides default behavior for URLSessionDownloadDelegate method `urlSession(_:downloadTask:didFinishDownloadingTo:)`. - open var downloadTaskDidFinishDownloadingToURL: ((URLSession, URLSessionDownloadTask, URL) -> Void)? - - /// Overrides default behavior for URLSessionDownloadDelegate method `urlSession(_:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:)`. - open var downloadTaskDidWriteData: ((URLSession, URLSessionDownloadTask, Int64, Int64, Int64) -> Void)? - - /// Overrides default behavior for URLSessionDownloadDelegate method `urlSession(_:downloadTask:didResumeAtOffset:expectedTotalBytes:)`. - open var downloadTaskDidResumeAtOffset: ((URLSession, URLSessionDownloadTask, Int64, Int64) -> Void)? - - // MARK: URLSessionStreamDelegate Overrides - -#if !os(watchOS) - - /// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:readClosedFor:)`. - @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) - open var streamTaskReadClosed: ((URLSession, URLSessionStreamTask) -> Void)? { - get { - return _streamTaskReadClosed as? (URLSession, URLSessionStreamTask) -> Void - } - set { - _streamTaskReadClosed = newValue - } - } - - /// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:writeClosedFor:)`. - @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) - open var streamTaskWriteClosed: ((URLSession, URLSessionStreamTask) -> Void)? { - get { - return _streamTaskWriteClosed as? (URLSession, URLSessionStreamTask) -> Void - } - set { - _streamTaskWriteClosed = newValue - } - } - - /// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:betterRouteDiscoveredFor:)`. - @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) - open var streamTaskBetterRouteDiscovered: ((URLSession, URLSessionStreamTask) -> Void)? { - get { - return _streamTaskBetterRouteDiscovered as? (URLSession, URLSessionStreamTask) -> Void - } - set { - _streamTaskBetterRouteDiscovered = newValue - } - } - - /// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:streamTask:didBecome:outputStream:)`. - @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) - open var streamTaskDidBecomeInputAndOutputStreams: ((URLSession, URLSessionStreamTask, InputStream, OutputStream) -> Void)? { - get { - return _streamTaskDidBecomeInputStream as? (URLSession, URLSessionStreamTask, InputStream, OutputStream) -> Void - } - set { - _streamTaskDidBecomeInputStream = newValue - } - } - - var _streamTaskReadClosed: Any? - var _streamTaskWriteClosed: Any? - var _streamTaskBetterRouteDiscovered: Any? - var _streamTaskDidBecomeInputStream: Any? - -#endif - - // MARK: Properties - - var retrier: RequestRetrier? - weak var sessionManager: SessionManager? - - var requests: [Int: Request] = [:] - private let lock = NSLock() - - /// Access the task delegate for the specified task in a thread-safe manner. - open subscript(task: URLSessionTask) -> Request? { - get { - lock.lock() ; defer { lock.unlock() } - return requests[task.taskIdentifier] - } - set { - lock.lock() ; defer { lock.unlock() } - requests[task.taskIdentifier] = newValue - } - } - - // MARK: Lifecycle - - /// Initializes the `SessionDelegate` instance. - /// - /// - returns: The new `SessionDelegate` instance. - public override init() { - super.init() - } - - // MARK: NSObject Overrides - - /// Returns a `Bool` indicating whether the `SessionDelegate` implements or inherits a method that can respond - /// to a specified message. - /// - /// - parameter selector: A selector that identifies a message. - /// - /// - returns: `true` if the receiver implements or inherits a method that can respond to selector, otherwise `false`. - open override func responds(to selector: Selector) -> Bool { - #if !os(macOS) - if selector == #selector(URLSessionDelegate.urlSessionDidFinishEvents(forBackgroundURLSession:)) { - return sessionDidFinishEventsForBackgroundURLSession != nil - } - #endif - - #if !os(watchOS) - if #available(iOS 9.0, macOS 10.11, tvOS 9.0, *) { - switch selector { - case #selector(URLSessionStreamDelegate.urlSession(_:readClosedFor:)): - return streamTaskReadClosed != nil - case #selector(URLSessionStreamDelegate.urlSession(_:writeClosedFor:)): - return streamTaskWriteClosed != nil - case #selector(URLSessionStreamDelegate.urlSession(_:betterRouteDiscoveredFor:)): - return streamTaskBetterRouteDiscovered != nil - case #selector(URLSessionStreamDelegate.urlSession(_:streamTask:didBecome:outputStream:)): - return streamTaskDidBecomeInputAndOutputStreams != nil - default: - break - } - } - #endif - - switch selector { - case #selector(URLSessionDelegate.urlSession(_:didBecomeInvalidWithError:)): - return sessionDidBecomeInvalidWithError != nil - case #selector(URLSessionDelegate.urlSession(_:didReceive:completionHandler:)): - return (sessionDidReceiveChallenge != nil || sessionDidReceiveChallengeWithCompletion != nil) - case #selector(URLSessionTaskDelegate.urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)): - return (taskWillPerformHTTPRedirection != nil || taskWillPerformHTTPRedirectionWithCompletion != nil) - case #selector(URLSessionDataDelegate.urlSession(_:dataTask:didReceive:completionHandler:)): - return (dataTaskDidReceiveResponse != nil || dataTaskDidReceiveResponseWithCompletion != nil) - default: - return type(of: self).instancesRespond(to: selector) - } - } -} - -// MARK: - URLSessionDelegate - -extension SessionDelegate: URLSessionDelegate { - /// Tells the delegate that the session has been invalidated. - /// - /// - parameter session: The session object that was invalidated. - /// - parameter error: The error that caused invalidation, or nil if the invalidation was explicit. - open func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?) { - sessionDidBecomeInvalidWithError?(session, error) - } - - /// Requests credentials from the delegate in response to a session-level authentication request from the - /// remote server. - /// - /// - parameter session: The session containing the task that requested authentication. - /// - parameter challenge: An object that contains the request for authentication. - /// - parameter completionHandler: A handler that your delegate method must call providing the disposition - /// and credential. - open func urlSession( - _ session: URLSession, - didReceive challenge: URLAuthenticationChallenge, - completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) - { - guard sessionDidReceiveChallengeWithCompletion == nil else { - sessionDidReceiveChallengeWithCompletion?(session, challenge, completionHandler) - return - } - - var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling - var credential: URLCredential? - - if let sessionDidReceiveChallenge = sessionDidReceiveChallenge { - (disposition, credential) = sessionDidReceiveChallenge(session, challenge) - } else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { - let host = challenge.protectionSpace.host - - if - let serverTrustPolicy = session.serverTrustPolicyManager?.serverTrustPolicy(forHost: host), - let serverTrust = challenge.protectionSpace.serverTrust - { - if serverTrustPolicy.evaluate(serverTrust, forHost: host) { - disposition = .useCredential - credential = URLCredential(trust: serverTrust) - } else { - disposition = .cancelAuthenticationChallenge - } - } - } - - completionHandler(disposition, credential) - } - -#if !os(macOS) - - /// Tells the delegate that all messages enqueued for a session have been delivered. - /// - /// - parameter session: The session that no longer has any outstanding requests. - open func urlSessionDidFinishEvents(forBackgroundURLSession session: URLSession) { - sessionDidFinishEventsForBackgroundURLSession?(session) - } - -#endif -} - -// MARK: - URLSessionTaskDelegate - -extension SessionDelegate: URLSessionTaskDelegate { - /// Tells the delegate that the remote server requested an HTTP redirect. - /// - /// - parameter session: The session containing the task whose request resulted in a redirect. - /// - parameter task: The task whose request resulted in a redirect. - /// - parameter response: An object containing the server’s response to the original request. - /// - parameter request: A URL request object filled out with the new location. - /// - parameter completionHandler: A closure that your handler should call with either the value of the request - /// parameter, a modified URL request object, or NULL to refuse the redirect and - /// return the body of the redirect response. - open func urlSession( - _ session: URLSession, - task: URLSessionTask, - willPerformHTTPRedirection response: HTTPURLResponse, - newRequest request: URLRequest, - completionHandler: @escaping (URLRequest?) -> Void) - { - guard taskWillPerformHTTPRedirectionWithCompletion == nil else { - taskWillPerformHTTPRedirectionWithCompletion?(session, task, response, request, completionHandler) - return - } - - var redirectRequest: URLRequest? = request - - if let taskWillPerformHTTPRedirection = taskWillPerformHTTPRedirection { - redirectRequest = taskWillPerformHTTPRedirection(session, task, response, request) - } - - completionHandler(redirectRequest) - } - - /// Requests credentials from the delegate in response to an authentication request from the remote server. - /// - /// - parameter session: The session containing the task whose request requires authentication. - /// - parameter task: The task whose request requires authentication. - /// - parameter challenge: An object that contains the request for authentication. - /// - parameter completionHandler: A handler that your delegate method must call providing the disposition - /// and credential. - open func urlSession( - _ session: URLSession, - task: URLSessionTask, - didReceive challenge: URLAuthenticationChallenge, - completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) - { - guard taskDidReceiveChallengeWithCompletion == nil else { - taskDidReceiveChallengeWithCompletion?(session, task, challenge, completionHandler) - return - } - - if let taskDidReceiveChallenge = taskDidReceiveChallenge { - let result = taskDidReceiveChallenge(session, task, challenge) - completionHandler(result.0, result.1) - } else if let delegate = self[task]?.delegate { - delegate.urlSession( - session, - task: task, - didReceive: challenge, - completionHandler: completionHandler - ) - } else { - urlSession(session, didReceive: challenge, completionHandler: completionHandler) - } - } - - /// Tells the delegate when a task requires a new request body stream to send to the remote server. - /// - /// - parameter session: The session containing the task that needs a new body stream. - /// - parameter task: The task that needs a new body stream. - /// - parameter completionHandler: A completion handler that your delegate method should call with the new body stream. - open func urlSession( - _ session: URLSession, - task: URLSessionTask, - needNewBodyStream completionHandler: @escaping (InputStream?) -> Void) - { - guard taskNeedNewBodyStreamWithCompletion == nil else { - taskNeedNewBodyStreamWithCompletion?(session, task, completionHandler) - return - } - - if let taskNeedNewBodyStream = taskNeedNewBodyStream { - completionHandler(taskNeedNewBodyStream(session, task)) - } else if let delegate = self[task]?.delegate { - delegate.urlSession(session, task: task, needNewBodyStream: completionHandler) - } - } - - /// Periodically informs the delegate of the progress of sending body content to the server. - /// - /// - parameter session: The session containing the data task. - /// - parameter task: The data task. - /// - parameter bytesSent: The number of bytes sent since the last time this delegate method was called. - /// - parameter totalBytesSent: The total number of bytes sent so far. - /// - parameter totalBytesExpectedToSend: The expected length of the body data. - open func urlSession( - _ session: URLSession, - task: URLSessionTask, - didSendBodyData bytesSent: Int64, - totalBytesSent: Int64, - totalBytesExpectedToSend: Int64) - { - if let taskDidSendBodyData = taskDidSendBodyData { - taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend) - } else if let delegate = self[task]?.delegate as? UploadTaskDelegate { - delegate.URLSession( - session, - task: task, - didSendBodyData: bytesSent, - totalBytesSent: totalBytesSent, - totalBytesExpectedToSend: totalBytesExpectedToSend - ) - } - } - -#if !os(watchOS) - - /// Tells the delegate that the session finished collecting metrics for the task. - /// - /// - parameter session: The session collecting the metrics. - /// - parameter task: The task whose metrics have been collected. - /// - parameter metrics: The collected metrics. - @available(iOS 10.0, macOS 10.12, tvOS 10.0, *) - @objc(URLSession:task:didFinishCollectingMetrics:) - open func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) { - self[task]?.delegate.metrics = metrics - } - -#endif - - /// Tells the delegate that the task finished transferring data. - /// - /// - parameter session: The session containing the task whose request finished transferring data. - /// - parameter task: The task whose request finished transferring data. - /// - parameter error: If an error occurred, an error object indicating how the transfer failed, otherwise nil. - open func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { - /// Executed after it is determined that the request is not going to be retried - let completeTask: (URLSession, URLSessionTask, Error?) -> Void = { [weak self] session, task, error in - guard let strongSelf = self else { return } - - strongSelf.taskDidComplete?(session, task, error) - - strongSelf[task]?.delegate.urlSession(session, task: task, didCompleteWithError: error) - - var userInfo: [String: Any] = [Notification.Key.Task: task] - - if let data = (strongSelf[task]?.delegate as? DataTaskDelegate)?.data { - userInfo[Notification.Key.ResponseData] = data - } - - NotificationCenter.default.post( - name: Notification.Name.Task.DidComplete, - object: strongSelf, - userInfo: userInfo - ) - - strongSelf[task] = nil - } - - guard let request = self[task], let sessionManager = sessionManager else { - completeTask(session, task, error) - return - } - - // Run all validations on the request before checking if an error occurred - request.validations.forEach { $0() } - - // Determine whether an error has occurred - var error: Error? = error - - if request.delegate.error != nil { - error = request.delegate.error - } - - /// If an error occurred and the retrier is set, asynchronously ask the retrier if the request - /// should be retried. Otherwise, complete the task by notifying the task delegate. - if let retrier = retrier, let error = error { - retrier.should(sessionManager, retry: request, with: error) { [weak self] shouldRetry, timeDelay in - guard shouldRetry else { completeTask(session, task, error) ; return } - - DispatchQueue.utility.after(timeDelay) { [weak self] in - guard let strongSelf = self else { return } - - let retrySucceeded = strongSelf.sessionManager?.retry(request) ?? false - - if retrySucceeded, let task = request.task { - strongSelf[task] = request - return - } else { - completeTask(session, task, error) - } - } - } - } else { - completeTask(session, task, error) - } - } -} - -// MARK: - URLSessionDataDelegate - -extension SessionDelegate: URLSessionDataDelegate { - /// Tells the delegate that the data task received the initial reply (headers) from the server. - /// - /// - parameter session: The session containing the data task that received an initial reply. - /// - parameter dataTask: The data task that received an initial reply. - /// - parameter response: A URL response object populated with headers. - /// - parameter completionHandler: A completion handler that your code calls to continue the transfer, passing a - /// constant to indicate whether the transfer should continue as a data task or - /// should become a download task. - open func urlSession( - _ session: URLSession, - dataTask: URLSessionDataTask, - didReceive response: URLResponse, - completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) - { - guard dataTaskDidReceiveResponseWithCompletion == nil else { - dataTaskDidReceiveResponseWithCompletion?(session, dataTask, response, completionHandler) - return - } - - var disposition: URLSession.ResponseDisposition = .allow - - if let dataTaskDidReceiveResponse = dataTaskDidReceiveResponse { - disposition = dataTaskDidReceiveResponse(session, dataTask, response) - } - - completionHandler(disposition) - } - - /// Tells the delegate that the data task was changed to a download task. - /// - /// - parameter session: The session containing the task that was replaced by a download task. - /// - parameter dataTask: The data task that was replaced by a download task. - /// - parameter downloadTask: The new download task that replaced the data task. - open func urlSession( - _ session: URLSession, - dataTask: URLSessionDataTask, - didBecome downloadTask: URLSessionDownloadTask) - { - if let dataTaskDidBecomeDownloadTask = dataTaskDidBecomeDownloadTask { - dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask) - } else { - self[downloadTask]?.delegate = DownloadTaskDelegate(task: downloadTask) - } - } - - /// Tells the delegate that the data task has received some of the expected data. - /// - /// - parameter session: The session containing the data task that provided data. - /// - parameter dataTask: The data task that provided data. - /// - parameter data: A data object containing the transferred data. - open func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { - if let dataTaskDidReceiveData = dataTaskDidReceiveData { - dataTaskDidReceiveData(session, dataTask, data) - } else if let delegate = self[dataTask]?.delegate as? DataTaskDelegate { - delegate.urlSession(session, dataTask: dataTask, didReceive: data) - } - } - - /// Asks the delegate whether the data (or upload) task should store the response in the cache. - /// - /// - parameter session: The session containing the data (or upload) task. - /// - parameter dataTask: The data (or upload) task. - /// - parameter proposedResponse: The default caching behavior. This behavior is determined based on the current - /// caching policy and the values of certain received headers, such as the Pragma - /// and Cache-Control headers. - /// - parameter completionHandler: A block that your handler must call, providing either the original proposed - /// response, a modified version of that response, or NULL to prevent caching the - /// response. If your delegate implements this method, it must call this completion - /// handler; otherwise, your app leaks memory. - open func urlSession( - _ session: URLSession, - dataTask: URLSessionDataTask, - willCacheResponse proposedResponse: CachedURLResponse, - completionHandler: @escaping (CachedURLResponse?) -> Void) - { - guard dataTaskWillCacheResponseWithCompletion == nil else { - dataTaskWillCacheResponseWithCompletion?(session, dataTask, proposedResponse, completionHandler) - return - } - - if let dataTaskWillCacheResponse = dataTaskWillCacheResponse { - completionHandler(dataTaskWillCacheResponse(session, dataTask, proposedResponse)) - } else if let delegate = self[dataTask]?.delegate as? DataTaskDelegate { - delegate.urlSession( - session, - dataTask: dataTask, - willCacheResponse: proposedResponse, - completionHandler: completionHandler - ) - } else { - completionHandler(proposedResponse) - } - } -} - -// MARK: - URLSessionDownloadDelegate - -extension SessionDelegate: URLSessionDownloadDelegate { - /// Tells the delegate that a download task has finished downloading. - /// - /// - parameter session: The session containing the download task that finished. - /// - parameter downloadTask: The download task that finished. - /// - parameter location: A file URL for the temporary file. Because the file is temporary, you must either - /// open the file for reading or move it to a permanent location in your app’s sandbox - /// container directory before returning from this delegate method. - open func urlSession( - _ session: URLSession, - downloadTask: URLSessionDownloadTask, - didFinishDownloadingTo location: URL) - { - if let downloadTaskDidFinishDownloadingToURL = downloadTaskDidFinishDownloadingToURL { - downloadTaskDidFinishDownloadingToURL(session, downloadTask, location) - } else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate { - delegate.urlSession(session, downloadTask: downloadTask, didFinishDownloadingTo: location) - } - } - - /// Periodically informs the delegate about the download’s progress. - /// - /// - parameter session: The session containing the download task. - /// - parameter downloadTask: The download task. - /// - parameter bytesWritten: The number of bytes transferred since the last time this delegate - /// method was called. - /// - parameter totalBytesWritten: The total number of bytes transferred so far. - /// - parameter totalBytesExpectedToWrite: The expected length of the file, as provided by the Content-Length - /// header. If this header was not provided, the value is - /// `NSURLSessionTransferSizeUnknown`. - open func urlSession( - _ session: URLSession, - downloadTask: URLSessionDownloadTask, - didWriteData bytesWritten: Int64, - totalBytesWritten: Int64, - totalBytesExpectedToWrite: Int64) - { - if let downloadTaskDidWriteData = downloadTaskDidWriteData { - downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) - } else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate { - delegate.urlSession( - session, - downloadTask: downloadTask, - didWriteData: bytesWritten, - totalBytesWritten: totalBytesWritten, - totalBytesExpectedToWrite: totalBytesExpectedToWrite - ) - } - } - - /// Tells the delegate that the download task has resumed downloading. - /// - /// - parameter session: The session containing the download task that finished. - /// - parameter downloadTask: The download task that resumed. See explanation in the discussion. - /// - parameter fileOffset: If the file's cache policy or last modified date prevents reuse of the - /// existing content, then this value is zero. Otherwise, this value is an - /// integer representing the number of bytes on disk that do not need to be - /// retrieved again. - /// - parameter expectedTotalBytes: The expected length of the file, as provided by the Content-Length header. - /// If this header was not provided, the value is NSURLSessionTransferSizeUnknown. - open func urlSession( - _ session: URLSession, - downloadTask: URLSessionDownloadTask, - didResumeAtOffset fileOffset: Int64, - expectedTotalBytes: Int64) - { - if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset { - downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes) - } else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate { - delegate.urlSession( - session, - downloadTask: downloadTask, - didResumeAtOffset: fileOffset, - expectedTotalBytes: expectedTotalBytes - ) - } - } -} - -// MARK: - URLSessionStreamDelegate - -#if !os(watchOS) - -@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) -extension SessionDelegate: URLSessionStreamDelegate { - /// Tells the delegate that the read side of the connection has been closed. - /// - /// - parameter session: The session. - /// - parameter streamTask: The stream task. - open func urlSession(_ session: URLSession, readClosedFor streamTask: URLSessionStreamTask) { - streamTaskReadClosed?(session, streamTask) - } - - /// Tells the delegate that the write side of the connection has been closed. - /// - /// - parameter session: The session. - /// - parameter streamTask: The stream task. - open func urlSession(_ session: URLSession, writeClosedFor streamTask: URLSessionStreamTask) { - streamTaskWriteClosed?(session, streamTask) - } - - /// Tells the delegate that the system has determined that a better route to the host is available. - /// - /// - parameter session: The session. - /// - parameter streamTask: The stream task. - open func urlSession(_ session: URLSession, betterRouteDiscoveredFor streamTask: URLSessionStreamTask) { - streamTaskBetterRouteDiscovered?(session, streamTask) - } - - /// Tells the delegate that the stream task has been completed and provides the unopened stream objects. - /// - /// - parameter session: The session. - /// - parameter streamTask: The stream task. - /// - parameter inputStream: The new input stream. - /// - parameter outputStream: The new output stream. - open func urlSession( - _ session: URLSession, - streamTask: URLSessionStreamTask, - didBecome inputStream: InputStream, - outputStream: OutputStream) - { - streamTaskDidBecomeInputAndOutputStreams?(session, streamTask, inputStream, outputStream) - } -} - -#endif diff --git a/Example/Pods/Alamofire/Source/SessionManager.swift b/Example/Pods/Alamofire/Source/SessionManager.swift deleted file mode 100644 index 02c36a7..0000000 --- a/Example/Pods/Alamofire/Source/SessionManager.swift +++ /dev/null @@ -1,899 +0,0 @@ -// -// SessionManager.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// Responsible for creating and managing `Request` objects, as well as their underlying `NSURLSession`. -open class SessionManager { - - // MARK: - Helper Types - - /// Defines whether the `MultipartFormData` encoding was successful and contains result of the encoding as - /// associated values. - /// - /// - Success: Represents a successful `MultipartFormData` encoding and contains the new `UploadRequest` along with - /// streaming information. - /// - Failure: Used to represent a failure in the `MultipartFormData` encoding and also contains the encoding - /// error. - public enum MultipartFormDataEncodingResult { - case success(request: UploadRequest, streamingFromDisk: Bool, streamFileURL: URL?) - case failure(Error) - } - - // MARK: - Properties - - /// A default instance of `SessionManager`, used by top-level Alamofire request methods, and suitable for use - /// directly for any ad hoc requests. - public static let `default`: SessionManager = { - let configuration = URLSessionConfiguration.default - configuration.httpAdditionalHeaders = SessionManager.defaultHTTPHeaders - - return SessionManager(configuration: configuration) - }() - - /// Creates default values for the "Accept-Encoding", "Accept-Language" and "User-Agent" headers. - public static let defaultHTTPHeaders: HTTPHeaders = { - // Accept-Encoding HTTP Header; see https://tools.ietf.org/html/rfc7230#section-4.2.3 - let acceptEncoding: String = "gzip;q=1.0, compress;q=0.5" - - // Accept-Language HTTP Header; see https://tools.ietf.org/html/rfc7231#section-5.3.5 - let acceptLanguage = Locale.preferredLanguages.prefix(6).enumerated().map { index, languageCode in - let quality = 1.0 - (Double(index) * 0.1) - return "\(languageCode);q=\(quality)" - }.joined(separator: ", ") - - // User-Agent Header; see https://tools.ietf.org/html/rfc7231#section-5.5.3 - // Example: `iOS Example/1.0 (org.alamofire.iOS-Example; build:1; iOS 10.0.0) Alamofire/4.0.0` - let userAgent: String = { - if let info = Bundle.main.infoDictionary { - let executable = info[kCFBundleExecutableKey as String] as? String ?? "Unknown" - let bundle = info[kCFBundleIdentifierKey as String] as? String ?? "Unknown" - let appVersion = info["CFBundleShortVersionString"] as? String ?? "Unknown" - let appBuild = info[kCFBundleVersionKey as String] as? String ?? "Unknown" - - let osNameVersion: String = { - let version = ProcessInfo.processInfo.operatingSystemVersion - let versionString = "\(version.majorVersion).\(version.minorVersion).\(version.patchVersion)" - - let osName: String = { - #if os(iOS) - return "iOS" - #elseif os(watchOS) - return "watchOS" - #elseif os(tvOS) - return "tvOS" - #elseif os(macOS) - return "OS X" - #elseif os(Linux) - return "Linux" - #else - return "Unknown" - #endif - }() - - return "\(osName) \(versionString)" - }() - - let alamofireVersion: String = { - guard - let afInfo = Bundle(for: SessionManager.self).infoDictionary, - let build = afInfo["CFBundleShortVersionString"] - else { return "Unknown" } - - return "Alamofire/\(build)" - }() - - return "\(executable)/\(appVersion) (\(bundle); build:\(appBuild); \(osNameVersion)) \(alamofireVersion)" - } - - return "Alamofire" - }() - - return [ - "Accept-Encoding": acceptEncoding, - "Accept-Language": acceptLanguage, - "User-Agent": userAgent - ] - }() - - /// Default memory threshold used when encoding `MultipartFormData` in bytes. - public static let multipartFormDataEncodingMemoryThreshold: UInt64 = 10_000_000 - - /// The underlying session. - public let session: URLSession - - /// The session delegate handling all the task and session delegate callbacks. - public let delegate: SessionDelegate - - /// Whether to start requests immediately after being constructed. `true` by default. - open var startRequestsImmediately: Bool = true - - /// The request adapter called each time a new request is created. - open var adapter: RequestAdapter? - - /// The request retrier called each time a request encounters an error to determine whether to retry the request. - open var retrier: RequestRetrier? { - get { return delegate.retrier } - set { delegate.retrier = newValue } - } - - /// The background completion handler closure provided by the UIApplicationDelegate - /// `application:handleEventsForBackgroundURLSession:completionHandler:` method. By setting the background - /// completion handler, the SessionDelegate `sessionDidFinishEventsForBackgroundURLSession` closure implementation - /// will automatically call the handler. - /// - /// If you need to handle your own events before the handler is called, then you need to override the - /// SessionDelegate `sessionDidFinishEventsForBackgroundURLSession` and manually call the handler when finished. - /// - /// `nil` by default. - open var backgroundCompletionHandler: (() -> Void)? - - let queue = DispatchQueue(label: "org.alamofire.session-manager." + UUID().uuidString) - - // MARK: - Lifecycle - - /// Creates an instance with the specified `configuration`, `delegate` and `serverTrustPolicyManager`. - /// - /// - parameter configuration: The configuration used to construct the managed session. - /// `URLSessionConfiguration.default` by default. - /// - parameter delegate: The delegate used when initializing the session. `SessionDelegate()` by - /// default. - /// - parameter serverTrustPolicyManager: The server trust policy manager to use for evaluating all server trust - /// challenges. `nil` by default. - /// - /// - returns: The new `SessionManager` instance. - public init( - configuration: URLSessionConfiguration = URLSessionConfiguration.default, - delegate: SessionDelegate = SessionDelegate(), - serverTrustPolicyManager: ServerTrustPolicyManager? = nil) - { - self.delegate = delegate - self.session = URLSession(configuration: configuration, delegate: delegate, delegateQueue: nil) - - commonInit(serverTrustPolicyManager: serverTrustPolicyManager) - } - - /// Creates an instance with the specified `session`, `delegate` and `serverTrustPolicyManager`. - /// - /// - parameter session: The URL session. - /// - parameter delegate: The delegate of the URL session. Must equal the URL session's delegate. - /// - parameter serverTrustPolicyManager: The server trust policy manager to use for evaluating all server trust - /// challenges. `nil` by default. - /// - /// - returns: The new `SessionManager` instance if the URL session's delegate matches; `nil` otherwise. - public init?( - session: URLSession, - delegate: SessionDelegate, - serverTrustPolicyManager: ServerTrustPolicyManager? = nil) - { - guard delegate === session.delegate else { return nil } - - self.delegate = delegate - self.session = session - - commonInit(serverTrustPolicyManager: serverTrustPolicyManager) - } - - private func commonInit(serverTrustPolicyManager: ServerTrustPolicyManager?) { - session.serverTrustPolicyManager = serverTrustPolicyManager - - delegate.sessionManager = self - - delegate.sessionDidFinishEventsForBackgroundURLSession = { [weak self] session in - guard let strongSelf = self else { return } - DispatchQueue.main.async { strongSelf.backgroundCompletionHandler?() } - } - } - - deinit { - session.invalidateAndCancel() - } - - // MARK: - Data Request - - /// Creates a `DataRequest` to retrieve the contents of the specified `url`, `method`, `parameters`, `encoding` - /// and `headers`. - /// - /// - parameter url: The URL. - /// - parameter method: The HTTP method. `.get` by default. - /// - parameter parameters: The parameters. `nil` by default. - /// - parameter encoding: The parameter encoding. `URLEncoding.default` by default. - /// - parameter headers: The HTTP headers. `nil` by default. - /// - /// - returns: The created `DataRequest`. - @discardableResult - open func request( - _ url: URLConvertible, - method: HTTPMethod = .get, - parameters: Parameters? = nil, - encoding: ParameterEncoding = URLEncoding.default, - headers: HTTPHeaders? = nil) - -> DataRequest - { - var originalRequest: URLRequest? - - do { - originalRequest = try URLRequest(url: url, method: method, headers: headers) - let encodedURLRequest = try encoding.encode(originalRequest!, with: parameters) - return request(encodedURLRequest) - } catch { - return request(originalRequest, failedWith: error) - } - } - - /// Creates a `DataRequest` to retrieve the contents of a URL based on the specified `urlRequest`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter urlRequest: The URL request. - /// - /// - returns: The created `DataRequest`. - @discardableResult - open func request(_ urlRequest: URLRequestConvertible) -> DataRequest { - var originalRequest: URLRequest? - - do { - originalRequest = try urlRequest.asURLRequest() - let originalTask = DataRequest.Requestable(urlRequest: originalRequest!) - - let task = try originalTask.task(session: session, adapter: adapter, queue: queue) - let request = DataRequest(session: session, requestTask: .data(originalTask, task)) - - delegate[task] = request - - if startRequestsImmediately { request.resume() } - - return request - } catch { - return request(originalRequest, failedWith: error) - } - } - - // MARK: Private - Request Implementation - - private func request(_ urlRequest: URLRequest?, failedWith error: Error) -> DataRequest { - var requestTask: Request.RequestTask = .data(nil, nil) - - if let urlRequest = urlRequest { - let originalTask = DataRequest.Requestable(urlRequest: urlRequest) - requestTask = .data(originalTask, nil) - } - - let underlyingError = error.underlyingAdaptError ?? error - let request = DataRequest(session: session, requestTask: requestTask, error: underlyingError) - - if let retrier = retrier, error is AdaptError { - allowRetrier(retrier, toRetry: request, with: underlyingError) - } else { - if startRequestsImmediately { request.resume() } - } - - return request - } - - // MARK: - Download Request - - // MARK: URL Request - - /// Creates a `DownloadRequest` to retrieve the contents the specified `url`, `method`, `parameters`, `encoding`, - /// `headers` and save them to the `destination`. - /// - /// If `destination` is not specified, the contents will remain in the temporary location determined by the - /// underlying URL session. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter url: The URL. - /// - parameter method: The HTTP method. `.get` by default. - /// - parameter parameters: The parameters. `nil` by default. - /// - parameter encoding: The parameter encoding. `URLEncoding.default` by default. - /// - parameter headers: The HTTP headers. `nil` by default. - /// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. - /// - /// - returns: The created `DownloadRequest`. - @discardableResult - open func download( - _ url: URLConvertible, - method: HTTPMethod = .get, - parameters: Parameters? = nil, - encoding: ParameterEncoding = URLEncoding.default, - headers: HTTPHeaders? = nil, - to destination: DownloadRequest.DownloadFileDestination? = nil) - -> DownloadRequest - { - do { - let urlRequest = try URLRequest(url: url, method: method, headers: headers) - let encodedURLRequest = try encoding.encode(urlRequest, with: parameters) - return download(encodedURLRequest, to: destination) - } catch { - return download(nil, to: destination, failedWith: error) - } - } - - /// Creates a `DownloadRequest` to retrieve the contents of a URL based on the specified `urlRequest` and save - /// them to the `destination`. - /// - /// If `destination` is not specified, the contents will remain in the temporary location determined by the - /// underlying URL session. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter urlRequest: The URL request - /// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. - /// - /// - returns: The created `DownloadRequest`. - @discardableResult - open func download( - _ urlRequest: URLRequestConvertible, - to destination: DownloadRequest.DownloadFileDestination? = nil) - -> DownloadRequest - { - do { - let urlRequest = try urlRequest.asURLRequest() - return download(.request(urlRequest), to: destination) - } catch { - return download(nil, to: destination, failedWith: error) - } - } - - // MARK: Resume Data - - /// Creates a `DownloadRequest` from the `resumeData` produced from a previous request cancellation to retrieve - /// the contents of the original request and save them to the `destination`. - /// - /// If `destination` is not specified, the contents will remain in the temporary location determined by the - /// underlying URL session. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken - /// on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the - /// data is written incorrectly and will always fail to resume the download. For more information about the bug and - /// possible workarounds, please refer to the following Stack Overflow post: - /// - /// - http://stackoverflow.com/a/39347461/1342462 - /// - /// - parameter resumeData: The resume data. This is an opaque data blob produced by `URLSessionDownloadTask` - /// when a task is cancelled. See `URLSession -downloadTask(withResumeData:)` for - /// additional information. - /// - parameter destination: The closure used to determine the destination of the downloaded file. `nil` by default. - /// - /// - returns: The created `DownloadRequest`. - @discardableResult - open func download( - resumingWith resumeData: Data, - to destination: DownloadRequest.DownloadFileDestination? = nil) - -> DownloadRequest - { - return download(.resumeData(resumeData), to: destination) - } - - // MARK: Private - Download Implementation - - private func download( - _ downloadable: DownloadRequest.Downloadable, - to destination: DownloadRequest.DownloadFileDestination?) - -> DownloadRequest - { - do { - let task = try downloadable.task(session: session, adapter: adapter, queue: queue) - let download = DownloadRequest(session: session, requestTask: .download(downloadable, task)) - - download.downloadDelegate.destination = destination - - delegate[task] = download - - if startRequestsImmediately { download.resume() } - - return download - } catch { - return download(downloadable, to: destination, failedWith: error) - } - } - - private func download( - _ downloadable: DownloadRequest.Downloadable?, - to destination: DownloadRequest.DownloadFileDestination?, - failedWith error: Error) - -> DownloadRequest - { - var downloadTask: Request.RequestTask = .download(nil, nil) - - if let downloadable = downloadable { - downloadTask = .download(downloadable, nil) - } - - let underlyingError = error.underlyingAdaptError ?? error - - let download = DownloadRequest(session: session, requestTask: downloadTask, error: underlyingError) - download.downloadDelegate.destination = destination - - if let retrier = retrier, error is AdaptError { - allowRetrier(retrier, toRetry: download, with: underlyingError) - } else { - if startRequestsImmediately { download.resume() } - } - - return download - } - - // MARK: - Upload Request - - // MARK: File - - /// Creates an `UploadRequest` from the specified `url`, `method` and `headers` for uploading the `file`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter file: The file to upload. - /// - parameter url: The URL. - /// - parameter method: The HTTP method. `.post` by default. - /// - parameter headers: The HTTP headers. `nil` by default. - /// - /// - returns: The created `UploadRequest`. - @discardableResult - open func upload( - _ fileURL: URL, - to url: URLConvertible, - method: HTTPMethod = .post, - headers: HTTPHeaders? = nil) - -> UploadRequest - { - do { - let urlRequest = try URLRequest(url: url, method: method, headers: headers) - return upload(fileURL, with: urlRequest) - } catch { - return upload(nil, failedWith: error) - } - } - - /// Creates a `UploadRequest` from the specified `urlRequest` for uploading the `file`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter file: The file to upload. - /// - parameter urlRequest: The URL request. - /// - /// - returns: The created `UploadRequest`. - @discardableResult - open func upload(_ fileURL: URL, with urlRequest: URLRequestConvertible) -> UploadRequest { - do { - let urlRequest = try urlRequest.asURLRequest() - return upload(.file(fileURL, urlRequest)) - } catch { - return upload(nil, failedWith: error) - } - } - - // MARK: Data - - /// Creates an `UploadRequest` from the specified `url`, `method` and `headers` for uploading the `data`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter data: The data to upload. - /// - parameter url: The URL. - /// - parameter method: The HTTP method. `.post` by default. - /// - parameter headers: The HTTP headers. `nil` by default. - /// - /// - returns: The created `UploadRequest`. - @discardableResult - open func upload( - _ data: Data, - to url: URLConvertible, - method: HTTPMethod = .post, - headers: HTTPHeaders? = nil) - -> UploadRequest - { - do { - let urlRequest = try URLRequest(url: url, method: method, headers: headers) - return upload(data, with: urlRequest) - } catch { - return upload(nil, failedWith: error) - } - } - - /// Creates an `UploadRequest` from the specified `urlRequest` for uploading the `data`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter data: The data to upload. - /// - parameter urlRequest: The URL request. - /// - /// - returns: The created `UploadRequest`. - @discardableResult - open func upload(_ data: Data, with urlRequest: URLRequestConvertible) -> UploadRequest { - do { - let urlRequest = try urlRequest.asURLRequest() - return upload(.data(data, urlRequest)) - } catch { - return upload(nil, failedWith: error) - } - } - - // MARK: InputStream - - /// Creates an `UploadRequest` from the specified `url`, `method` and `headers` for uploading the `stream`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter stream: The stream to upload. - /// - parameter url: The URL. - /// - parameter method: The HTTP method. `.post` by default. - /// - parameter headers: The HTTP headers. `nil` by default. - /// - /// - returns: The created `UploadRequest`. - @discardableResult - open func upload( - _ stream: InputStream, - to url: URLConvertible, - method: HTTPMethod = .post, - headers: HTTPHeaders? = nil) - -> UploadRequest - { - do { - let urlRequest = try URLRequest(url: url, method: method, headers: headers) - return upload(stream, with: urlRequest) - } catch { - return upload(nil, failedWith: error) - } - } - - /// Creates an `UploadRequest` from the specified `urlRequest` for uploading the `stream`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter stream: The stream to upload. - /// - parameter urlRequest: The URL request. - /// - /// - returns: The created `UploadRequest`. - @discardableResult - open func upload(_ stream: InputStream, with urlRequest: URLRequestConvertible) -> UploadRequest { - do { - let urlRequest = try urlRequest.asURLRequest() - return upload(.stream(stream, urlRequest)) - } catch { - return upload(nil, failedWith: error) - } - } - - // MARK: MultipartFormData - - /// Encodes `multipartFormData` using `encodingMemoryThreshold` and calls `encodingCompletion` with new - /// `UploadRequest` using the `url`, `method` and `headers`. - /// - /// It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative - /// payload is small, encoding the data in-memory and directly uploading to a server is the by far the most - /// efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to - /// be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory - /// footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be - /// used for larger payloads such as video content. - /// - /// The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory - /// or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, - /// encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk - /// during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding - /// technique was used. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. - /// - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. - /// `multipartFormDataEncodingMemoryThreshold` by default. - /// - parameter url: The URL. - /// - parameter method: The HTTP method. `.post` by default. - /// - parameter headers: The HTTP headers. `nil` by default. - /// - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. - open func upload( - multipartFormData: @escaping (MultipartFormData) -> Void, - usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, - to url: URLConvertible, - method: HTTPMethod = .post, - headers: HTTPHeaders? = nil, - queue: DispatchQueue? = nil, - encodingCompletion: ((MultipartFormDataEncodingResult) -> Void)?) - { - do { - let urlRequest = try URLRequest(url: url, method: method, headers: headers) - - return upload( - multipartFormData: multipartFormData, - usingThreshold: encodingMemoryThreshold, - with: urlRequest, - queue: queue, - encodingCompletion: encodingCompletion - ) - } catch { - (queue ?? DispatchQueue.main).async { encodingCompletion?(.failure(error)) } - } - } - - /// Encodes `multipartFormData` using `encodingMemoryThreshold` and calls `encodingCompletion` with new - /// `UploadRequest` using the `urlRequest`. - /// - /// It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative - /// payload is small, encoding the data in-memory and directly uploading to a server is the by far the most - /// efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to - /// be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory - /// footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be - /// used for larger payloads such as video content. - /// - /// The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory - /// or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, - /// encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk - /// during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding - /// technique was used. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. - /// - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. - /// `multipartFormDataEncodingMemoryThreshold` by default. - /// - parameter urlRequest: The URL request. - /// - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. - open func upload( - multipartFormData: @escaping (MultipartFormData) -> Void, - usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, - with urlRequest: URLRequestConvertible, - queue: DispatchQueue? = nil, - encodingCompletion: ((MultipartFormDataEncodingResult) -> Void)?) - { - DispatchQueue.global(qos: .utility).async { - let formData = MultipartFormData() - multipartFormData(formData) - - var tempFileURL: URL? - - do { - var urlRequestWithContentType = try urlRequest.asURLRequest() - urlRequestWithContentType.setValue(formData.contentType, forHTTPHeaderField: "Content-Type") - - let isBackgroundSession = self.session.configuration.identifier != nil - - if formData.contentLength < encodingMemoryThreshold && !isBackgroundSession { - let data = try formData.encode() - - let encodingResult = MultipartFormDataEncodingResult.success( - request: self.upload(data, with: urlRequestWithContentType), - streamingFromDisk: false, - streamFileURL: nil - ) - - (queue ?? DispatchQueue.main).async { encodingCompletion?(encodingResult) } - } else { - let fileManager = FileManager.default - let tempDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory()) - let directoryURL = tempDirectoryURL.appendingPathComponent("org.alamofire.manager/multipart.form.data") - let fileName = UUID().uuidString - let fileURL = directoryURL.appendingPathComponent(fileName) - - tempFileURL = fileURL - - var directoryError: Error? - - // Create directory inside serial queue to ensure two threads don't do this in parallel - self.queue.sync { - do { - try fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true, attributes: nil) - } catch { - directoryError = error - } - } - - if let directoryError = directoryError { throw directoryError } - - try formData.writeEncodedData(to: fileURL) - - let upload = self.upload(fileURL, with: urlRequestWithContentType) - - // Cleanup the temp file once the upload is complete - upload.delegate.queue.addOperation { - do { - try FileManager.default.removeItem(at: fileURL) - } catch { - // No-op - } - } - - (queue ?? DispatchQueue.main).async { - let encodingResult = MultipartFormDataEncodingResult.success( - request: upload, - streamingFromDisk: true, - streamFileURL: fileURL - ) - - encodingCompletion?(encodingResult) - } - } - } catch { - // Cleanup the temp file in the event that the multipart form data encoding failed - if let tempFileURL = tempFileURL { - do { - try FileManager.default.removeItem(at: tempFileURL) - } catch { - // No-op - } - } - - (queue ?? DispatchQueue.main).async { encodingCompletion?(.failure(error)) } - } - } - } - - // MARK: Private - Upload Implementation - - private func upload(_ uploadable: UploadRequest.Uploadable) -> UploadRequest { - do { - let task = try uploadable.task(session: session, adapter: adapter, queue: queue) - let upload = UploadRequest(session: session, requestTask: .upload(uploadable, task)) - - if case let .stream(inputStream, _) = uploadable { - upload.delegate.taskNeedNewBodyStream = { _, _ in inputStream } - } - - delegate[task] = upload - - if startRequestsImmediately { upload.resume() } - - return upload - } catch { - return upload(uploadable, failedWith: error) - } - } - - private func upload(_ uploadable: UploadRequest.Uploadable?, failedWith error: Error) -> UploadRequest { - var uploadTask: Request.RequestTask = .upload(nil, nil) - - if let uploadable = uploadable { - uploadTask = .upload(uploadable, nil) - } - - let underlyingError = error.underlyingAdaptError ?? error - let upload = UploadRequest(session: session, requestTask: uploadTask, error: underlyingError) - - if let retrier = retrier, error is AdaptError { - allowRetrier(retrier, toRetry: upload, with: underlyingError) - } else { - if startRequestsImmediately { upload.resume() } - } - - return upload - } - -#if !os(watchOS) - - // MARK: - Stream Request - - // MARK: Hostname and Port - - /// Creates a `StreamRequest` for bidirectional streaming using the `hostname` and `port`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter hostName: The hostname of the server to connect to. - /// - parameter port: The port of the server to connect to. - /// - /// - returns: The created `StreamRequest`. - @discardableResult - @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) - open func stream(withHostName hostName: String, port: Int) -> StreamRequest { - return stream(.stream(hostName: hostName, port: port)) - } - - // MARK: NetService - - /// Creates a `StreamRequest` for bidirectional streaming using the `netService`. - /// - /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. - /// - /// - parameter netService: The net service used to identify the endpoint. - /// - /// - returns: The created `StreamRequest`. - @discardableResult - @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) - open func stream(with netService: NetService) -> StreamRequest { - return stream(.netService(netService)) - } - - // MARK: Private - Stream Implementation - - @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) - private func stream(_ streamable: StreamRequest.Streamable) -> StreamRequest { - do { - let task = try streamable.task(session: session, adapter: adapter, queue: queue) - let request = StreamRequest(session: session, requestTask: .stream(streamable, task)) - - delegate[task] = request - - if startRequestsImmediately { request.resume() } - - return request - } catch { - return stream(failedWith: error) - } - } - - @available(iOS 9.0, macOS 10.11, tvOS 9.0, *) - private func stream(failedWith error: Error) -> StreamRequest { - let stream = StreamRequest(session: session, requestTask: .stream(nil, nil), error: error) - if startRequestsImmediately { stream.resume() } - return stream - } - -#endif - - // MARK: - Internal - Retry Request - - func retry(_ request: Request) -> Bool { - guard let originalTask = request.originalTask else { return false } - - do { - let task = try originalTask.task(session: session, adapter: adapter, queue: queue) - - if let originalTask = request.task { - delegate[originalTask] = nil // removes the old request to avoid endless growth - } - - request.delegate.task = task // resets all task delegate data - - request.retryCount += 1 - request.startTime = CFAbsoluteTimeGetCurrent() - request.endTime = nil - - task.resume() - - return true - } catch { - request.delegate.error = error.underlyingAdaptError ?? error - return false - } - } - - private func allowRetrier(_ retrier: RequestRetrier, toRetry request: Request, with error: Error) { - DispatchQueue.utility.async { [weak self] in - guard let strongSelf = self else { return } - - retrier.should(strongSelf, retry: request, with: error) { shouldRetry, timeDelay in - guard let strongSelf = self else { return } - - guard shouldRetry else { - if strongSelf.startRequestsImmediately { request.resume() } - return - } - - DispatchQueue.utility.after(timeDelay) { - guard let strongSelf = self else { return } - - let retrySucceeded = strongSelf.retry(request) - - if retrySucceeded, let task = request.task { - strongSelf.delegate[task] = request - } else { - if strongSelf.startRequestsImmediately { request.resume() } - } - } - } - } - } -} diff --git a/Example/Pods/Alamofire/Source/TaskDelegate.swift b/Example/Pods/Alamofire/Source/TaskDelegate.swift deleted file mode 100644 index 5705737..0000000 --- a/Example/Pods/Alamofire/Source/TaskDelegate.swift +++ /dev/null @@ -1,466 +0,0 @@ -// -// TaskDelegate.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// The task delegate is responsible for handling all delegate callbacks for the underlying task as well as -/// executing all operations attached to the serial operation queue upon task completion. -open class TaskDelegate: NSObject { - - // MARK: Properties - - /// The serial operation queue used to execute all operations after the task completes. - public let queue: OperationQueue - - /// The data returned by the server. - public var data: Data? { return nil } - - /// The error generated throughout the lifecyle of the task. - public var error: Error? - - var task: URLSessionTask? { - set { - taskLock.lock(); defer { taskLock.unlock() } - _task = newValue - } - get { - taskLock.lock(); defer { taskLock.unlock() } - return _task - } - } - - var initialResponseTime: CFAbsoluteTime? - var credential: URLCredential? - var metrics: AnyObject? // URLSessionTaskMetrics - - private var _task: URLSessionTask? { - didSet { reset() } - } - - private let taskLock = NSLock() - - // MARK: Lifecycle - - init(task: URLSessionTask?) { - _task = task - - self.queue = { - let operationQueue = OperationQueue() - - operationQueue.maxConcurrentOperationCount = 1 - operationQueue.isSuspended = true - operationQueue.qualityOfService = .utility - - return operationQueue - }() - } - - func reset() { - error = nil - initialResponseTime = nil - } - - // MARK: URLSessionTaskDelegate - - var taskWillPerformHTTPRedirection: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest) -> URLRequest?)? - var taskDidReceiveChallenge: ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))? - var taskNeedNewBodyStream: ((URLSession, URLSessionTask) -> InputStream?)? - var taskDidCompleteWithError: ((URLSession, URLSessionTask, Error?) -> Void)? - - @objc(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:) - func urlSession( - _ session: URLSession, - task: URLSessionTask, - willPerformHTTPRedirection response: HTTPURLResponse, - newRequest request: URLRequest, - completionHandler: @escaping (URLRequest?) -> Void) - { - var redirectRequest: URLRequest? = request - - if let taskWillPerformHTTPRedirection = taskWillPerformHTTPRedirection { - redirectRequest = taskWillPerformHTTPRedirection(session, task, response, request) - } - - completionHandler(redirectRequest) - } - - @objc(URLSession:task:didReceiveChallenge:completionHandler:) - func urlSession( - _ session: URLSession, - task: URLSessionTask, - didReceive challenge: URLAuthenticationChallenge, - completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) - { - var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling - var credential: URLCredential? - - if let taskDidReceiveChallenge = taskDidReceiveChallenge { - (disposition, credential) = taskDidReceiveChallenge(session, task, challenge) - } else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { - let host = challenge.protectionSpace.host - - if - let serverTrustPolicy = session.serverTrustPolicyManager?.serverTrustPolicy(forHost: host), - let serverTrust = challenge.protectionSpace.serverTrust - { - if serverTrustPolicy.evaluate(serverTrust, forHost: host) { - disposition = .useCredential - credential = URLCredential(trust: serverTrust) - } else { - disposition = .cancelAuthenticationChallenge - } - } - } else { - if challenge.previousFailureCount > 0 { - disposition = .rejectProtectionSpace - } else { - credential = self.credential ?? session.configuration.urlCredentialStorage?.defaultCredential(for: challenge.protectionSpace) - - if credential != nil { - disposition = .useCredential - } - } - } - - completionHandler(disposition, credential) - } - - @objc(URLSession:task:needNewBodyStream:) - func urlSession( - _ session: URLSession, - task: URLSessionTask, - needNewBodyStream completionHandler: @escaping (InputStream?) -> Void) - { - var bodyStream: InputStream? - - if let taskNeedNewBodyStream = taskNeedNewBodyStream { - bodyStream = taskNeedNewBodyStream(session, task) - } - - completionHandler(bodyStream) - } - - @objc(URLSession:task:didCompleteWithError:) - func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { - if let taskDidCompleteWithError = taskDidCompleteWithError { - taskDidCompleteWithError(session, task, error) - } else { - if let error = error { - if self.error == nil { self.error = error } - - if - let downloadDelegate = self as? DownloadTaskDelegate, - let resumeData = (error as NSError).userInfo[NSURLSessionDownloadTaskResumeData] as? Data - { - downloadDelegate.resumeData = resumeData - } - } - - queue.isSuspended = false - } - } -} - -// MARK: - - -class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate { - - // MARK: Properties - - var dataTask: URLSessionDataTask { return task as! URLSessionDataTask } - - override var data: Data? { - if dataStream != nil { - return nil - } else { - return mutableData - } - } - - var progress: Progress - var progressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)? - - var dataStream: ((_ data: Data) -> Void)? - - private var totalBytesReceived: Int64 = 0 - private var mutableData: Data - - private var expectedContentLength: Int64? - - // MARK: Lifecycle - - override init(task: URLSessionTask?) { - mutableData = Data() - progress = Progress(totalUnitCount: 0) - - super.init(task: task) - } - - override func reset() { - super.reset() - - progress = Progress(totalUnitCount: 0) - totalBytesReceived = 0 - mutableData = Data() - expectedContentLength = nil - } - - // MARK: URLSessionDataDelegate - - var dataTaskDidReceiveResponse: ((URLSession, URLSessionDataTask, URLResponse) -> URLSession.ResponseDisposition)? - var dataTaskDidBecomeDownloadTask: ((URLSession, URLSessionDataTask, URLSessionDownloadTask) -> Void)? - var dataTaskDidReceiveData: ((URLSession, URLSessionDataTask, Data) -> Void)? - var dataTaskWillCacheResponse: ((URLSession, URLSessionDataTask, CachedURLResponse) -> CachedURLResponse?)? - - func urlSession( - _ session: URLSession, - dataTask: URLSessionDataTask, - didReceive response: URLResponse, - completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) - { - var disposition: URLSession.ResponseDisposition = .allow - - expectedContentLength = response.expectedContentLength - - if let dataTaskDidReceiveResponse = dataTaskDidReceiveResponse { - disposition = dataTaskDidReceiveResponse(session, dataTask, response) - } - - completionHandler(disposition) - } - - func urlSession( - _ session: URLSession, - dataTask: URLSessionDataTask, - didBecome downloadTask: URLSessionDownloadTask) - { - dataTaskDidBecomeDownloadTask?(session, dataTask, downloadTask) - } - - func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { - if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() } - - if let dataTaskDidReceiveData = dataTaskDidReceiveData { - dataTaskDidReceiveData(session, dataTask, data) - } else { - if let dataStream = dataStream { - dataStream(data) - } else { - mutableData.append(data) - } - - let bytesReceived = Int64(data.count) - totalBytesReceived += bytesReceived - let totalBytesExpected = dataTask.response?.expectedContentLength ?? NSURLSessionTransferSizeUnknown - - progress.totalUnitCount = totalBytesExpected - progress.completedUnitCount = totalBytesReceived - - if let progressHandler = progressHandler { - progressHandler.queue.async { progressHandler.closure(self.progress) } - } - } - } - - func urlSession( - _ session: URLSession, - dataTask: URLSessionDataTask, - willCacheResponse proposedResponse: CachedURLResponse, - completionHandler: @escaping (CachedURLResponse?) -> Void) - { - var cachedResponse: CachedURLResponse? = proposedResponse - - if let dataTaskWillCacheResponse = dataTaskWillCacheResponse { - cachedResponse = dataTaskWillCacheResponse(session, dataTask, proposedResponse) - } - - completionHandler(cachedResponse) - } -} - -// MARK: - - -class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate { - - // MARK: Properties - - var downloadTask: URLSessionDownloadTask { return task as! URLSessionDownloadTask } - - var progress: Progress - var progressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)? - - var resumeData: Data? - override var data: Data? { return resumeData } - - var destination: DownloadRequest.DownloadFileDestination? - - var temporaryURL: URL? - var destinationURL: URL? - - var fileURL: URL? { return destination != nil ? destinationURL : temporaryURL } - - // MARK: Lifecycle - - override init(task: URLSessionTask?) { - progress = Progress(totalUnitCount: 0) - super.init(task: task) - } - - override func reset() { - super.reset() - - progress = Progress(totalUnitCount: 0) - resumeData = nil - } - - // MARK: URLSessionDownloadDelegate - - var downloadTaskDidFinishDownloadingToURL: ((URLSession, URLSessionDownloadTask, URL) -> URL)? - var downloadTaskDidWriteData: ((URLSession, URLSessionDownloadTask, Int64, Int64, Int64) -> Void)? - var downloadTaskDidResumeAtOffset: ((URLSession, URLSessionDownloadTask, Int64, Int64) -> Void)? - - func urlSession( - _ session: URLSession, - downloadTask: URLSessionDownloadTask, - didFinishDownloadingTo location: URL) - { - temporaryURL = location - - guard - let destination = destination, - let response = downloadTask.response as? HTTPURLResponse - else { return } - - let result = destination(location, response) - let destinationURL = result.destinationURL - let options = result.options - - self.destinationURL = destinationURL - - do { - if options.contains(.removePreviousFile), FileManager.default.fileExists(atPath: destinationURL.path) { - try FileManager.default.removeItem(at: destinationURL) - } - - if options.contains(.createIntermediateDirectories) { - let directory = destinationURL.deletingLastPathComponent() - try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) - } - - try FileManager.default.moveItem(at: location, to: destinationURL) - } catch { - self.error = error - } - } - - func urlSession( - _ session: URLSession, - downloadTask: URLSessionDownloadTask, - didWriteData bytesWritten: Int64, - totalBytesWritten: Int64, - totalBytesExpectedToWrite: Int64) - { - if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() } - - if let downloadTaskDidWriteData = downloadTaskDidWriteData { - downloadTaskDidWriteData( - session, - downloadTask, - bytesWritten, - totalBytesWritten, - totalBytesExpectedToWrite - ) - } else { - progress.totalUnitCount = totalBytesExpectedToWrite - progress.completedUnitCount = totalBytesWritten - - if let progressHandler = progressHandler { - progressHandler.queue.async { progressHandler.closure(self.progress) } - } - } - } - - func urlSession( - _ session: URLSession, - downloadTask: URLSessionDownloadTask, - didResumeAtOffset fileOffset: Int64, - expectedTotalBytes: Int64) - { - if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset { - downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes) - } else { - progress.totalUnitCount = expectedTotalBytes - progress.completedUnitCount = fileOffset - } - } -} - -// MARK: - - -class UploadTaskDelegate: DataTaskDelegate { - - // MARK: Properties - - var uploadTask: URLSessionUploadTask { return task as! URLSessionUploadTask } - - var uploadProgress: Progress - var uploadProgressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)? - - // MARK: Lifecycle - - override init(task: URLSessionTask?) { - uploadProgress = Progress(totalUnitCount: 0) - super.init(task: task) - } - - override func reset() { - super.reset() - uploadProgress = Progress(totalUnitCount: 0) - } - - // MARK: URLSessionTaskDelegate - - var taskDidSendBodyData: ((URLSession, URLSessionTask, Int64, Int64, Int64) -> Void)? - - func URLSession( - _ session: URLSession, - task: URLSessionTask, - didSendBodyData bytesSent: Int64, - totalBytesSent: Int64, - totalBytesExpectedToSend: Int64) - { - if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() } - - if let taskDidSendBodyData = taskDidSendBodyData { - taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend) - } else { - uploadProgress.totalUnitCount = totalBytesExpectedToSend - uploadProgress.completedUnitCount = totalBytesSent - - if let uploadProgressHandler = uploadProgressHandler { - uploadProgressHandler.queue.async { uploadProgressHandler.closure(self.uploadProgress) } - } - } - } -} diff --git a/Example/Pods/Alamofire/Source/Timeline.swift b/Example/Pods/Alamofire/Source/Timeline.swift deleted file mode 100644 index 596c1bd..0000000 --- a/Example/Pods/Alamofire/Source/Timeline.swift +++ /dev/null @@ -1,136 +0,0 @@ -// -// Timeline.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -/// Responsible for computing the timing metrics for the complete lifecycle of a `Request`. -public struct Timeline { - /// The time the request was initialized. - public let requestStartTime: CFAbsoluteTime - - /// The time the first bytes were received from or sent to the server. - public let initialResponseTime: CFAbsoluteTime - - /// The time when the request was completed. - public let requestCompletedTime: CFAbsoluteTime - - /// The time when the response serialization was completed. - public let serializationCompletedTime: CFAbsoluteTime - - /// The time interval in seconds from the time the request started to the initial response from the server. - public let latency: TimeInterval - - /// The time interval in seconds from the time the request started to the time the request completed. - public let requestDuration: TimeInterval - - /// The time interval in seconds from the time the request completed to the time response serialization completed. - public let serializationDuration: TimeInterval - - /// The time interval in seconds from the time the request started to the time response serialization completed. - public let totalDuration: TimeInterval - - /// Creates a new `Timeline` instance with the specified request times. - /// - /// - parameter requestStartTime: The time the request was initialized. Defaults to `0.0`. - /// - parameter initialResponseTime: The time the first bytes were received from or sent to the server. - /// Defaults to `0.0`. - /// - parameter requestCompletedTime: The time when the request was completed. Defaults to `0.0`. - /// - parameter serializationCompletedTime: The time when the response serialization was completed. Defaults - /// to `0.0`. - /// - /// - returns: The new `Timeline` instance. - public init( - requestStartTime: CFAbsoluteTime = 0.0, - initialResponseTime: CFAbsoluteTime = 0.0, - requestCompletedTime: CFAbsoluteTime = 0.0, - serializationCompletedTime: CFAbsoluteTime = 0.0) - { - self.requestStartTime = requestStartTime - self.initialResponseTime = initialResponseTime - self.requestCompletedTime = requestCompletedTime - self.serializationCompletedTime = serializationCompletedTime - - self.latency = initialResponseTime - requestStartTime - self.requestDuration = requestCompletedTime - requestStartTime - self.serializationDuration = serializationCompletedTime - requestCompletedTime - self.totalDuration = serializationCompletedTime - requestStartTime - } -} - -// MARK: - CustomStringConvertible - -extension Timeline: CustomStringConvertible { - /// The textual representation used when written to an output stream, which includes the latency, the request - /// duration and the total duration. - public var description: String { - let latency = String(format: "%.3f", self.latency) - let requestDuration = String(format: "%.3f", self.requestDuration) - let serializationDuration = String(format: "%.3f", self.serializationDuration) - let totalDuration = String(format: "%.3f", self.totalDuration) - - // NOTE: Had to move to string concatenation due to memory leak filed as rdar://26761490. Once memory leak is - // fixed, we should move back to string interpolation by reverting commit 7d4a43b1. - let timings = [ - "\"Latency\": " + latency + " secs", - "\"Request Duration\": " + requestDuration + " secs", - "\"Serialization Duration\": " + serializationDuration + " secs", - "\"Total Duration\": " + totalDuration + " secs" - ] - - return "Timeline: { " + timings.joined(separator: ", ") + " }" - } -} - -// MARK: - CustomDebugStringConvertible - -extension Timeline: CustomDebugStringConvertible { - /// The textual representation used when written to an output stream, which includes the request start time, the - /// initial response time, the request completed time, the serialization completed time, the latency, the request - /// duration and the total duration. - public var debugDescription: String { - let requestStartTime = String(format: "%.3f", self.requestStartTime) - let initialResponseTime = String(format: "%.3f", self.initialResponseTime) - let requestCompletedTime = String(format: "%.3f", self.requestCompletedTime) - let serializationCompletedTime = String(format: "%.3f", self.serializationCompletedTime) - let latency = String(format: "%.3f", self.latency) - let requestDuration = String(format: "%.3f", self.requestDuration) - let serializationDuration = String(format: "%.3f", self.serializationDuration) - let totalDuration = String(format: "%.3f", self.totalDuration) - - // NOTE: Had to move to string concatenation due to memory leak filed as rdar://26761490. Once memory leak is - // fixed, we should move back to string interpolation by reverting commit 7d4a43b1. - let timings = [ - "\"Request Start Time\": " + requestStartTime, - "\"Initial Response Time\": " + initialResponseTime, - "\"Request Completed Time\": " + requestCompletedTime, - "\"Serialization Completed Time\": " + serializationCompletedTime, - "\"Latency\": " + latency + " secs", - "\"Request Duration\": " + requestDuration + " secs", - "\"Serialization Duration\": " + serializationDuration + " secs", - "\"Total Duration\": " + totalDuration + " secs" - ] - - return "Timeline: { " + timings.joined(separator: ", ") + " }" - } -} diff --git a/Example/Pods/Alamofire/Source/Validation.swift b/Example/Pods/Alamofire/Source/Validation.swift deleted file mode 100644 index 5640789..0000000 --- a/Example/Pods/Alamofire/Source/Validation.swift +++ /dev/null @@ -1,315 +0,0 @@ -// -// Validation.swift -// -// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// 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. -// - -import Foundation - -extension Request { - - // MARK: Helper Types - - fileprivate typealias ErrorReason = AFError.ResponseValidationFailureReason - - /// Used to represent whether validation was successful or encountered an error resulting in a failure. - /// - /// - success: The validation was successful. - /// - failure: The validation failed encountering the provided error. - public enum ValidationResult { - case success - case failure(Error) - } - - fileprivate struct MIMEType { - let type: String - let subtype: String - - var isWildcard: Bool { return type == "*" && subtype == "*" } - - init?(_ string: String) { - let components: [String] = { - let stripped = string.trimmingCharacters(in: .whitespacesAndNewlines) - - #if swift(>=3.2) - let split = stripped[..<(stripped.range(of: ";")?.lowerBound ?? stripped.endIndex)] - #else - let split = stripped.substring(to: stripped.range(of: ";")?.lowerBound ?? stripped.endIndex) - #endif - - return split.components(separatedBy: "/") - }() - - if let type = components.first, let subtype = components.last { - self.type = type - self.subtype = subtype - } else { - return nil - } - } - - func matches(_ mime: MIMEType) -> Bool { - switch (type, subtype) { - case (mime.type, mime.subtype), (mime.type, "*"), ("*", mime.subtype), ("*", "*"): - return true - default: - return false - } - } - } - - // MARK: Properties - - fileprivate var acceptableStatusCodes: [Int] { return Array(200..<300) } - - fileprivate var acceptableContentTypes: [String] { - if let accept = request?.value(forHTTPHeaderField: "Accept") { - return accept.components(separatedBy: ",") - } - - return ["*/*"] - } - - // MARK: Status Code - - fileprivate func validate( - statusCode acceptableStatusCodes: S, - response: HTTPURLResponse) - -> ValidationResult - where S.Iterator.Element == Int - { - if acceptableStatusCodes.contains(response.statusCode) { - return .success - } else { - let reason: ErrorReason = .unacceptableStatusCode(code: response.statusCode) - return .failure(AFError.responseValidationFailed(reason: reason)) - } - } - - // MARK: Content Type - - fileprivate func validate( - contentType acceptableContentTypes: S, - response: HTTPURLResponse, - data: Data?) - -> ValidationResult - where S.Iterator.Element == String - { - guard let data = data, data.count > 0 else { return .success } - - guard - let responseContentType = response.mimeType, - let responseMIMEType = MIMEType(responseContentType) - else { - for contentType in acceptableContentTypes { - if let mimeType = MIMEType(contentType), mimeType.isWildcard { - return .success - } - } - - let error: AFError = { - let reason: ErrorReason = .missingContentType(acceptableContentTypes: Array(acceptableContentTypes)) - return AFError.responseValidationFailed(reason: reason) - }() - - return .failure(error) - } - - for contentType in acceptableContentTypes { - if let acceptableMIMEType = MIMEType(contentType), acceptableMIMEType.matches(responseMIMEType) { - return .success - } - } - - let error: AFError = { - let reason: ErrorReason = .unacceptableContentType( - acceptableContentTypes: Array(acceptableContentTypes), - responseContentType: responseContentType - ) - - return AFError.responseValidationFailed(reason: reason) - }() - - return .failure(error) - } -} - -// MARK: - - -extension DataRequest { - /// A closure used to validate a request that takes a URL request, a URL response and data, and returns whether the - /// request was valid. - public typealias Validation = (URLRequest?, HTTPURLResponse, Data?) -> ValidationResult - - /// Validates the request, using the specified closure. - /// - /// If validation fails, subsequent calls to response handlers will have an associated error. - /// - /// - parameter validation: A closure to validate the request. - /// - /// - returns: The request. - @discardableResult - public func validate(_ validation: @escaping Validation) -> Self { - let validationExecution: () -> Void = { [unowned self] in - if - let response = self.response, - self.delegate.error == nil, - case let .failure(error) = validation(self.request, response, self.delegate.data) - { - self.delegate.error = error - } - } - - validations.append(validationExecution) - - return self - } - - /// Validates that the response has a status code in the specified sequence. - /// - /// If validation fails, subsequent calls to response handlers will have an associated error. - /// - /// - parameter range: The range of acceptable status codes. - /// - /// - returns: The request. - @discardableResult - public func validate(statusCode acceptableStatusCodes: S) -> Self where S.Iterator.Element == Int { - return validate { [unowned self] _, response, _ in - return self.validate(statusCode: acceptableStatusCodes, response: response) - } - } - - /// Validates that the response has a content type in the specified sequence. - /// - /// If validation fails, subsequent calls to response handlers will have an associated error. - /// - /// - parameter contentType: The acceptable content types, which may specify wildcard types and/or subtypes. - /// - /// - returns: The request. - @discardableResult - public func validate(contentType acceptableContentTypes: S) -> Self where S.Iterator.Element == String { - return validate { [unowned self] _, response, data in - return self.validate(contentType: acceptableContentTypes, response: response, data: data) - } - } - - /// Validates that the response has a status code in the default acceptable range of 200...299, and that the content - /// type matches any specified in the Accept HTTP header field. - /// - /// If validation fails, subsequent calls to response handlers will have an associated error. - /// - /// - returns: The request. - @discardableResult - public func validate() -> Self { - return validate(statusCode: self.acceptableStatusCodes).validate(contentType: self.acceptableContentTypes) - } -} - -// MARK: - - -extension DownloadRequest { - /// A closure used to validate a request that takes a URL request, a URL response, a temporary URL and a - /// destination URL, and returns whether the request was valid. - public typealias Validation = ( - _ request: URLRequest?, - _ response: HTTPURLResponse, - _ temporaryURL: URL?, - _ destinationURL: URL?) - -> ValidationResult - - /// Validates the request, using the specified closure. - /// - /// If validation fails, subsequent calls to response handlers will have an associated error. - /// - /// - parameter validation: A closure to validate the request. - /// - /// - returns: The request. - @discardableResult - public func validate(_ validation: @escaping Validation) -> Self { - let validationExecution: () -> Void = { [unowned self] in - let request = self.request - let temporaryURL = self.downloadDelegate.temporaryURL - let destinationURL = self.downloadDelegate.destinationURL - - if - let response = self.response, - self.delegate.error == nil, - case let .failure(error) = validation(request, response, temporaryURL, destinationURL) - { - self.delegate.error = error - } - } - - validations.append(validationExecution) - - return self - } - - /// Validates that the response has a status code in the specified sequence. - /// - /// If validation fails, subsequent calls to response handlers will have an associated error. - /// - /// - parameter range: The range of acceptable status codes. - /// - /// - returns: The request. - @discardableResult - public func validate(statusCode acceptableStatusCodes: S) -> Self where S.Iterator.Element == Int { - return validate { [unowned self] _, response, _, _ in - return self.validate(statusCode: acceptableStatusCodes, response: response) - } - } - - /// Validates that the response has a content type in the specified sequence. - /// - /// If validation fails, subsequent calls to response handlers will have an associated error. - /// - /// - parameter contentType: The acceptable content types, which may specify wildcard types and/or subtypes. - /// - /// - returns: The request. - @discardableResult - public func validate(contentType acceptableContentTypes: S) -> Self where S.Iterator.Element == String { - return validate { [unowned self] _, response, _, _ in - let fileURL = self.downloadDelegate.fileURL - - guard let validFileURL = fileURL else { - return .failure(AFError.responseValidationFailed(reason: .dataFileNil)) - } - - do { - let data = try Data(contentsOf: validFileURL) - return self.validate(contentType: acceptableContentTypes, response: response, data: data) - } catch { - return .failure(AFError.responseValidationFailed(reason: .dataFileReadFailed(at: validFileURL))) - } - } - } - - /// Validates that the response has a status code in the default acceptable range of 200...299, and that the content - /// type matches any specified in the Accept HTTP header field. - /// - /// If validation fails, subsequent calls to response handlers will have an associated error. - /// - /// - returns: The request. - @discardableResult - public func validate() -> Self { - return validate(statusCode: self.acceptableStatusCodes).validate(contentType: self.acceptableContentTypes) - } -} diff --git a/Example/Pods/Apollo/LICENSE b/Example/Pods/Apollo/LICENSE deleted file mode 100644 index 688165d..0000000 --- a/Example/Pods/Apollo/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016-2017 Meteor Development Group, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -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. diff --git a/Example/Pods/Apollo/README.md b/Example/Pods/Apollo/README.md deleted file mode 100644 index c43d2c1..0000000 --- a/Example/Pods/Apollo/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Apollo iOS - -[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg?maxAge=2592000)](https://raw.githubusercontent.com/apollographql/apollo-ios/master/LICENSE) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/Apollo.svg)](https://cocoapods.org/pods/Apollo) [![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](http://www.apollodata.com/#slack) - -Apollo iOS is a strongly-typed, caching GraphQL client for iOS, written in Swift. - -It allows you to execute queries and mutations against a GraphQL server, and returns results as query-specific Swift types. This means you don’t have to deal with parsing JSON, or passing around dictionaries and making clients cast values to the right type manually. You also don't have to write model types yourself, because these are generated from the GraphQL definitions your UI uses. - -As the generated types are query-specific, you're only able to access data you actually specify as part of a query. If you don't ask for a field, you won't be able to access the corresponding property. In effect, this means you can now rely on the Swift type checker to make sure errors in data access show up at compile time. With our Xcode integration, you can conveniently work with your UI code and corresponding GraphQL definitions side by side, and it will even validate your query documents, and show errors inline. - -Apollo iOS does more than simply run your queries against a GraphQL server however. It normalizes query results to construct a client-side cache of your data, which is kept up to date as further queries and mutations are run. This means your UI is always internally consistent, and can be kept fully up-to-date with the state on the server with the minimum number of queries required. - -This combination of models with value semantics, one way data flow, and automatic consistency management, leads to a very powerful and elegant programming model that allows you to eliminate common glue code and greatly simplifies app development. - -## Documentation - -[Read the full docs at apollographql.com/docs/ios/](https://www.apollographql.com/docs/ios/) - -## Changelog -[Read about the latest changes to the library](https://github.com/apollographql/apollo-ios/blob/master/CHANGELOG.md) - -## Contributing - -[![Build status](https://travis-ci.org/apollographql/apollo-ios.svg?branch=master)](https://travis-ci.org/apollographql/apollo-ios) - -This project is being developed using Xcode 9 and Swift 4. - -If you open `Apollo.xcodeproj`, you should be able to run the tests of the Apollo target. - -Some of the tests run against [a simple GraphQL server serving the Star Wars example schema](https://github.com/apollographql/starwars-server) (see installation instructions there). - -If you'd like to contribute, please refer to the [Apollo Contributor Guide](https://github.com/apollographql/apollo-ios/blob/master/CONTRIBUTING.md). diff --git a/Example/Pods/Apollo/Sources/Apollo/ApolloClient.swift b/Example/Pods/Apollo/Sources/Apollo/ApolloClient.swift deleted file mode 100644 index f740867..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/ApolloClient.swift +++ /dev/null @@ -1,249 +0,0 @@ -import Foundation -import Dispatch - -/// An object that can be used to cancel an in progress action. -public protocol Cancellable: class { - /// Cancel an in progress action. - func cancel() -} - -/// A cache policy that specifies whether results should be fetched from the server or loaded from the local cache. -public enum CachePolicy { - /// Return data from the cache if available, else fetch results from the server. - case returnCacheDataElseFetch - /// Always fetch results from the server. - case fetchIgnoringCacheData - /// Return data from the cache if available, else return nil. - case returnCacheDataDontFetch - /// Return data from the cache if available, and always fetch results from the server. - case returnCacheDataAndFetch -} - -/// A handler for operation results. -/// -/// - Parameters: -/// - result: The result of the performed operation, or `nil` if an error occurred. -/// - error: An error that indicates why the mutation failed, or `nil` if the mutation was succesful. -public typealias OperationResultHandler = (_ result: GraphQLResult?, _ error: Error?) -> Void - -/// The `ApolloClient` class provides the core API for Apollo. This API provides methods to fetch and watch queries, and to perform mutations. -public class ApolloClient { - let networkTransport: NetworkTransport - - public let store: ApolloStore - - public var cacheKeyForObject: CacheKeyForObject? { - get { - return store.cacheKeyForObject - } - - set { - store.cacheKeyForObject = newValue - } - } - - private let queue: DispatchQueue - private let operationQueue: OperationQueue - - /// Creates a client with the specified network transport and store. - /// - /// - Parameters: - /// - networkTransport: A network transport used to send operations to a server. - /// - store: A store used as a local cache. Defaults to an empty store backed by an in memory cache. - public init(networkTransport: NetworkTransport, store: ApolloStore = ApolloStore(cache: InMemoryNormalizedCache())) { - self.networkTransport = networkTransport - self.store = store - - queue = DispatchQueue(label: "com.apollographql.ApolloClient", attributes: .concurrent) - operationQueue = OperationQueue() - } - - /// Creates a client with an HTTP network transport connecting to the specified URL. - /// - /// - Parameter url: The URL of a GraphQL server to connect to. - public convenience init(url: URL) { - self.init(networkTransport: HTTPNetworkTransport(url: url)) - } - - /// Clears apollo cache - /// - /// - Returns: Promise - public func clearCache() -> Promise { - return store.clearCache() - } - - /// Fetches a query from the server or from the local cache, depending on the current contents of the cache and the specified cache policy. - /// - /// - Parameters: - /// - query: The query to fetch. - /// - cachePolicy: A cache policy that specifies when results should be fetched from the server and when data should be loaded from the local cache. - /// - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue. - /// - resultHandler: An optional closure that is called when query results are available or when an error occurs. - /// - Returns: An object that can be used to cancel an in progress fetch. - @discardableResult public func fetch(query: Query, cachePolicy: CachePolicy = .returnCacheDataElseFetch, queue: DispatchQueue = DispatchQueue.main, resultHandler: OperationResultHandler? = nil) -> Cancellable { - return _fetch(query: query, cachePolicy: cachePolicy, queue: queue, resultHandler: resultHandler) - } - - func _fetch(query: Query, cachePolicy: CachePolicy, context: UnsafeMutableRawPointer? = nil, queue: DispatchQueue, resultHandler: OperationResultHandler?) -> Cancellable { - // If we don't have to go through the cache, there is no need to create an operation - // and we can return a network task directly - if cachePolicy == .fetchIgnoringCacheData { - return send(operation: query, context: context, handlerQueue: queue, resultHandler: resultHandler) - } else { - let operation = FetchQueryOperation(client: self, query: query, cachePolicy: cachePolicy, context: context, handlerQueue: queue, resultHandler: resultHandler) - operationQueue.addOperation(operation) - return operation - } - } - - /// Watches a query by first fetching an initial result from the server or from the local cache, depending on the current contents of the cache and the specified cache policy. After the initial fetch, the returned query watcher object will get notified whenever any of the data the query result depends on changes in the local cache, and calls the result handler again with the new result. - /// - /// - Parameters: - /// - query: The query to fetch. - /// - cachePolicy: A cache policy that specifies when results should be fetched from the server or from the local cache. - /// - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue. - /// - resultHandler: An optional closure that is called when query results are available or when an error occurs. - /// - Returns: A query watcher object that can be used to control the watching behavior. - public func watch(query: Query, cachePolicy: CachePolicy = .returnCacheDataElseFetch, queue: DispatchQueue = DispatchQueue.main, resultHandler: @escaping OperationResultHandler) -> GraphQLQueryWatcher { - let watcher = GraphQLQueryWatcher(client: self, query: query, handlerQueue: queue, resultHandler: resultHandler) - watcher.fetch(cachePolicy: cachePolicy) - return watcher - } - - /// Performs a mutation by sending it to the server. - /// - /// - Parameters: - /// - mutation: The mutation to perform. - /// - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue. - /// - resultHandler: An optional closure that is called when mutation results are available or when an error occurs. - /// - Returns: An object that can be used to cancel an in progress mutation. - @discardableResult public func perform(mutation: Mutation, queue: DispatchQueue = DispatchQueue.main, resultHandler: OperationResultHandler? = nil) -> Cancellable { - return _perform(mutation: mutation, queue: queue, resultHandler: resultHandler) - } - - func _perform(mutation: Mutation, context: UnsafeMutableRawPointer? = nil, queue: DispatchQueue, resultHandler: OperationResultHandler?) -> Cancellable { - return send(operation: mutation, context: context, handlerQueue: queue, resultHandler: resultHandler) - } - - /// Subscribe to a subscription - /// - /// - Parameters: - /// - subscription: The subscription to subscribe to. - /// - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue. - /// - resultHandler: An optional closure that is called when mutation results are available or when an error occurs. - /// - Returns: An object that can be used to cancel an in progress subscription. - @discardableResult public func subscribe(subscription: Subscription, queue: DispatchQueue = DispatchQueue.main, resultHandler: @escaping OperationResultHandler) -> Cancellable { - return send(operation: subscription, context: nil, handlerQueue: queue, resultHandler: resultHandler) - } - - - fileprivate func send(operation: Operation, context: UnsafeMutableRawPointer?, handlerQueue: DispatchQueue, resultHandler: OperationResultHandler?) -> Cancellable { - func notifyResultHandler(result: GraphQLResult?, error: Error?) { - guard let resultHandler = resultHandler else { return } - - handlerQueue.async { - resultHandler(result, error) - } - } - - return networkTransport.send(operation: operation) { (response, error) in - guard let response = response else { - notifyResultHandler(result: nil, error: error) - return - } - - firstly { - try response.parseResult(cacheKeyForObject: self.cacheKeyForObject) - }.andThen { (result, records) in - notifyResultHandler(result: result, error: nil) - - if let records = records { - self.store.publish(records: records, context: context).catch { error in - preconditionFailure(String(describing: error)) - } - } - }.catch { error in - notifyResultHandler(result: nil, error: error) - } - } - } -} - -private final class FetchQueryOperation: AsynchronousOperation, Cancellable { - let client: ApolloClient - let query: Query - let cachePolicy: CachePolicy - let context: UnsafeMutableRawPointer? - let handlerQueue: DispatchQueue - let resultHandler: OperationResultHandler? - - private var networkTask: Cancellable? - - init(client: ApolloClient, query: Query, cachePolicy: CachePolicy, context: UnsafeMutableRawPointer?, handlerQueue: DispatchQueue, resultHandler: OperationResultHandler?) { - self.client = client - self.query = query - self.cachePolicy = cachePolicy - self.context = context - self.handlerQueue = handlerQueue - self.resultHandler = resultHandler - } - - override public func start() { - if isCancelled { - state = .finished - return - } - - state = .executing - - if cachePolicy == .fetchIgnoringCacheData { - fetchFromNetwork() - return - } - - client.store.load(query: query) { (result, error) in - if error == nil { - self.notifyResultHandler(result: result, error: nil) - - if self.cachePolicy != .returnCacheDataAndFetch { - self.state = .finished - return - } - } - - if self.isCancelled { - self.state = .finished - return - } - - if self.cachePolicy == .returnCacheDataDontFetch { - self.notifyResultHandler(result: nil, error: nil) - self.state = .finished - return - } - - self.fetchFromNetwork() - } - } - - func fetchFromNetwork() { - networkTask = client.send(operation: query, context: context, handlerQueue: handlerQueue) { (result, error) in - self.notifyResultHandler(result: result, error: error) - self.state = .finished - return - } - } - - override public func cancel() { - super.cancel() - networkTask?.cancel() - } - - func notifyResultHandler(result: GraphQLResult?, error: Error?) { - guard let resultHandler = resultHandler else { return } - - handlerQueue.async { - resultHandler(result, error) - } - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/ApolloStore.swift b/Example/Pods/Apollo/Sources/Apollo/ApolloStore.swift deleted file mode 100644 index 30510e6..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/ApolloStore.swift +++ /dev/null @@ -1,249 +0,0 @@ -import Dispatch - -/// A function that returns a cache key for a particular result object. If it returns `nil`, a default cache key based on the field path will be used. -public typealias CacheKeyForObject = (_ object: JSONObject) -> JSONValue? -public typealias DidChangeKeysFunc = (Set, UnsafeMutableRawPointer?) -> Void - -func rootCacheKey(for operation: Operation) -> String { - switch operation.operationType { - case .query: - return "QUERY_ROOT" - case .mutation: - return "MUTATION_ROOT" - case .subscription: - return "SUBSCRIPTION_ROOT" - } -} - -protocol ApolloStoreSubscriber: class { - func store(_ store: ApolloStore, didChangeKeys changedKeys: Set, context: UnsafeMutableRawPointer?) -} - -/// The `ApolloStore` class acts as a local cache for normalized GraphQL results. -public final class ApolloStore { - public var cacheKeyForObject: CacheKeyForObject? - - private let queue: DispatchQueue - - private let cache: NormalizedCache - - // We need a separate read/write lock for cache access because cache operations are - // asynchronous and we don't want to block the dispatch threads - private let cacheLock = ReadWriteLock() - - private var subscribers: [ApolloStoreSubscriber] = [] - - public init(cache: NormalizedCache) { - self.cache = cache - queue = DispatchQueue(label: "com.apollographql.ApolloStore", attributes: .concurrent) - } - - fileprivate func didChangeKeys(_ changedKeys: Set, context: UnsafeMutableRawPointer?) { - for subscriber in self.subscribers { - subscriber.store(self, didChangeKeys: changedKeys, context: context) - } - } - - func clearCache() -> Promise { - return Promise { fulfill, reject in - queue.async(flags: .barrier) { - self.cacheLock.withWriteLock { - self.cache.clear() - }.andThen { - fulfill(()) - } - } - } - } - - func publish(records: RecordSet, context: UnsafeMutableRawPointer? = nil) -> Promise { - return Promise { fulfill, reject in - queue.async(flags: .barrier) { - self.cacheLock.withWriteLock { - self.cache.merge(records: records) - }.andThen { changedKeys in - self.didChangeKeys(changedKeys, context: context) - fulfill(()) - } - } - } - } - - func subscribe(_ subscriber: ApolloStoreSubscriber) { - queue.async(flags: .barrier) { - self.subscribers.append(subscriber) - } - } - - func unsubscribe(_ subscriber: ApolloStoreSubscriber) { - queue.async(flags: .barrier) { - self.subscribers = self.subscribers.filter({ $0 !== subscriber }) - } - } - - public func withinReadTransaction(_ body: @escaping (ReadTransaction) throws -> Promise) -> Promise { - return Promise { fulfill, reject in - self.queue.async { - self.cacheLock.lockForReading() - - fulfill(ReadTransaction(cache: self.cache, cacheKeyForObject: self.cacheKeyForObject)) - } - }.flatMap(body) - .finally { - self.cacheLock.unlock() - } - } - - public func withinReadTransaction(_ body: @escaping (ReadTransaction) throws -> T) -> Promise { - return withinReadTransaction { - Promise(fulfilled: try body($0)) - } - } - - public func withinReadWriteTransaction(_ body: @escaping (ReadWriteTransaction) throws -> Promise) -> Promise { - return Promise { fulfill, reject in - self.queue.async(flags: .barrier) { - self.cacheLock.lockForWriting() - fulfill(ReadWriteTransaction(cache: self.cache, cacheKeyForObject: self.cacheKeyForObject, updateChangedKeysFunc: self.didChangeKeys)) - } - }.flatMap(body) - .finally { - self.cacheLock.unlock() - } - } - - public func withinReadWriteTransaction(_ body: @escaping (ReadWriteTransaction) throws -> T) -> Promise { - return withinReadWriteTransaction { - Promise(fulfilled: try body($0)) - } - } - - public func load(query: Query) -> Promise> { - return withinReadTransaction { transaction in - let mapper = GraphQLSelectionSetMapper() - let dependencyTracker = GraphQLDependencyTracker() - - return try transaction.execute(selections: Query.Data.selections, onObjectWithKey: rootCacheKey(for: query), variables: query.variables, accumulator: zip(mapper, dependencyTracker)) - }.map { (data: Query.Data, dependentKeys: Set) in - GraphQLResult(data: data, errors: nil, source:.cache, dependentKeys: dependentKeys) - } - } - - public func load(query: Query, resultHandler: @escaping OperationResultHandler) { - load(query: query).andThen { result in - resultHandler(result, nil) - }.catch { error in - resultHandler(nil, error) - } - } - - public class ReadTransaction { - fileprivate let cache: NormalizedCache - fileprivate let cacheKeyForObject: CacheKeyForObject? - - fileprivate lazy var loader: DataLoader = DataLoader(self.cache.loadRecords) - - init(cache: NormalizedCache, cacheKeyForObject: CacheKeyForObject?) { - self.cache = cache - self.cacheKeyForObject = cacheKeyForObject - } - - public func read(query: Query) throws -> Query.Data { - return try readObject(ofType: Query.Data.self, withKey: rootCacheKey(for: query), variables: query.variables) - } - - public func readObject(ofType type: SelectionSet.Type, withKey key: CacheKey, variables: GraphQLMap? = nil) throws -> SelectionSet { - let mapper = GraphQLSelectionSetMapper() - return try execute(selections: type.selections, onObjectWithKey: key, variables: variables, accumulator: mapper).await() - } - - public func loadRecords(forKeys keys: [CacheKey]) -> Promise<[Record?]> { - return cache.loadRecords(forKeys: keys) - } - - private final func complete(value: Any?) -> ResultOrPromise { - if let reference = value as? Reference { - return .promise(loader[reference.key].map { $0?.fields }) - } else if let array = value as? Array { - let completedValues = array.map(complete) - // Make sure to dispatch on a global queue and not on the local queue, - // because that could result in a deadlock (if someone is waiting for the write lock). - return whenAll(completedValues, notifyOn: .global()).map { $0 } - } else { - return .result(.success(value)) - } - } - - final func execute(selections: [GraphQLSelection], onObjectWithKey key: CacheKey, variables: GraphQLMap?, accumulator: Accumulator) throws -> Promise { - return loadObject(forKey: key).flatMap { object in - let executor = GraphQLExecutor { object, info in - let value = object[info.cacheKeyForField] - return self.complete(value: value) - } - - - executor.dispatchDataLoads = self.loader.dispatch - executor.cacheKeyForObject = self.cacheKeyForObject - - return try executor.execute(selections: selections, on: object, withKey: key, variables: variables, accumulator: accumulator) - } - } - - private final func loadObject(forKey key: CacheKey) -> Promise { - defer { loader.dispatch() } - - return loader[key].map { record in - guard let object = record?.fields else { throw JSONDecodingError.missingValue } - return object - } - } - } - - public final class ReadWriteTransaction: ReadTransaction { - - fileprivate var updateChangedKeysFunc: DidChangeKeysFunc? - - init(cache: NormalizedCache, cacheKeyForObject: CacheKeyForObject?, updateChangedKeysFunc: @escaping DidChangeKeysFunc) { - self.updateChangedKeysFunc = updateChangedKeysFunc - super.init(cache: cache, cacheKeyForObject: cacheKeyForObject) - } - - public func update(query: Query, _ body: (inout Query.Data) throws -> Void) throws { - var data = try read(query: query) - try body(&data) - try write(data: data, forQuery: query) - } - - public func updateObject(ofType type: SelectionSet.Type, withKey key: CacheKey, variables: GraphQLMap? = nil, _ body: (inout SelectionSet) throws -> Void) throws { - var object = try readObject(ofType: type, withKey: key, variables: variables) - try body(&object) - try write(object: object, withKey: key, variables: variables) - } - - public func write(data: Query.Data, forQuery query: Query) throws { - try write(object: data, withKey: rootCacheKey(for: query), variables: query.variables) - } - - public func write(object: GraphQLSelectionSet, withKey key: CacheKey, variables: GraphQLMap? = nil) throws { - try write(object: object.jsonObject, forSelections: type(of: object).selections, withKey: key, variables: variables) - } - - private func write(object: JSONObject, forSelections selections: [GraphQLSelection], withKey key: CacheKey, variables: GraphQLMap?) throws { - let normalizer = GraphQLResultNormalizer() - let executor = GraphQLExecutor { object, info in - return .result(.success(object[info.responseKeyForField])) - } - - executor.cacheKeyForObject = self.cacheKeyForObject - - try executor.execute(selections: selections, on: object, withKey: key, variables: variables, accumulator: normalizer) - .flatMap { - self.cache.merge(records: $0) - }.andThen { changedKeys in - if let didChangeKeysFunc = self.updateChangedKeysFunc { - didChangeKeysFunc(changedKeys, nil) - } - }.wait() - } - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/AsynchronousOperation.swift b/Example/Pods/Apollo/Sources/Apollo/AsynchronousOperation.swift deleted file mode 100644 index 381b6f0..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/AsynchronousOperation.swift +++ /dev/null @@ -1,47 +0,0 @@ -import Foundation - -class AsynchronousOperation: Operation { - @objc class func keyPathsForValuesAffectingIsExecuting() -> Set { - return ["state"] - } - - @objc class func keyPathsForValuesAffectingIsFinished() -> Set { - return ["state"] - } - - enum State { - case initialized - case ready - case executing - case finished - } - - var state: State = .initialized { - willSet { - willChangeValue(forKey: "state") - } - didSet { - didChangeValue(forKey: "state") - } - } - - override var isAsynchronous: Bool { - return true - } - - override var isReady: Bool { - let ready = super.isReady - if ready { - state = .ready - } - return ready - } - - override var isExecuting: Bool { - return state == .executing - } - - override var isFinished: Bool { - return state == .finished - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/Collections.swift b/Example/Pods/Apollo/Sources/Apollo/Collections.swift deleted file mode 100644 index f9282fb..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/Collections.swift +++ /dev/null @@ -1,100 +0,0 @@ -public extension Dictionary { - static func += (lhs: inout Dictionary, rhs: Dictionary) { - #if swift(>=3.2) - lhs.merge(rhs) { (_, new) in new } - #else - for (key, value) in rhs { - lhs[key] = value - } - #endif - } -} - -extension Dictionary { - init(_ entries: S) where S.Iterator.Element == Element { - self = Dictionary(minimumCapacity: entries.underestimatedCount) - for (key, value) in entries { - self[key] = value - } - } -} - -struct GroupedSequence { - private(set) var keys: [Key] = [] - fileprivate var groupsForKeys: [[Value]] = [] - - mutating func append(value: Value, forKey key: Key) -> (Int, Int) { - if let index = keys.index(where: { $0 == key }) { - groupsForKeys[index].append(value) - return (index, groupsForKeys[index].endIndex - 1) - } else { - keys.append(key) - groupsForKeys.append([value]) - return (keys.endIndex - 1, 0) - } - } -} - -extension GroupedSequence: Sequence { - func makeIterator() -> GroupedSequenceIterator { - return GroupedSequenceIterator(base: self) - } -} - -struct GroupedSequenceIterator: IteratorProtocol { - private var base: GroupedSequence - - private var keyIterator: EnumeratedSequence>.Iterator - - init(base: GroupedSequence) { - self.base = base - keyIterator = base.keys.enumerated().makeIterator() - } - - mutating func next() -> (Key, [Value])? { - if let (index, key) = keyIterator.next() { - let values = base.groupsForKeys[index] - return (key, values) - } else { - return nil - } - } -} - -public func unzip(_ array: [(Element1, Element2)]) -> ([Element1], [Element2]) { - var array1: [Element1] = [] - var array2: [Element2] = [] - - for element in array { - array1.append(element.0) - array2.append(element.1) - } - - return (array1, array2) -} - -public func unzip(_ array: [(Element1, Element2, Element3)]) -> ([Element1], [Element2], [Element3]) { - var array1: [Element1] = [] - var array2: [Element2] = [] - var array3: [Element3] = [] - - for element in array { - array1.append(element.0) - array2.append(element.1) - array3.append(element.2) - } - - return (array1, array2, array3) -} - -public func unzip(_ array: [[Element]], count: Int) -> [[Element]] { - var unzippedArray: [[Element]] = Array(repeating: [], count: count) - - for valuesForElement in array { - for (index, value) in valuesForElement.enumerated() { - unzippedArray[index].append(value) - } - } - - return unzippedArray -} diff --git a/Example/Pods/Apollo/Sources/Apollo/DataLoader.swift b/Example/Pods/Apollo/Sources/Apollo/DataLoader.swift deleted file mode 100644 index 6b3d05a..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/DataLoader.swift +++ /dev/null @@ -1,57 +0,0 @@ -import Dispatch - -public final class DataLoader { - public typealias BatchLoad = ([Key]) -> Promise<[Value]> - typealias Load = (key: Key, fulfill: (Value) -> Void, reject: (Error) -> Void) - - private let queue: DispatchQueue - - private var batchLoad: BatchLoad - - private var cache: [Key: Promise] = [:] - private var loads: [Load] = [] - - public init(_ batchLoad: @escaping BatchLoad) { - queue = DispatchQueue(label: "com.apollographql.DataLoader") - - self.batchLoad = batchLoad - } - - subscript(key: Key) -> Promise { - if let promise = cache[key] { - return promise - } - - let promise = Promise { fulfill, reject in - enqueue(load: (key, fulfill, reject)) - } - - cache[key] = promise - - return promise - } - - private func enqueue(load: Load) { - queue.async { - self.loads.append(load) - } - } - - func dispatch() { - queue.async { - let loads = self.loads - - if loads.isEmpty { return } - - self.loads = [] - - let keys = loads.map { $0.key } - - self.batchLoad(keys).andThen { values in - for (load, value) in zip(loads, values) { - load.fulfill(value) - } - } - } - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLDependencyTracker.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLDependencyTracker.swift deleted file mode 100644 index 879ee6f..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLDependencyTracker.swift +++ /dev/null @@ -1,26 +0,0 @@ -final class GraphQLDependencyTracker: GraphQLResultAccumulator { - private var dependentKeys: Set = Set() - - func accept(scalar: JSONValue, info: GraphQLResolveInfo) { - dependentKeys.insert(joined(path: info.cachePath)) - } - - func acceptNullValue(info: GraphQLResolveInfo) { - dependentKeys.insert(joined(path: info.cachePath)) - } - - func accept(list: [Void], info: GraphQLResolveInfo) { - dependentKeys.insert(joined(path: info.cachePath)) - } - - func accept(fieldEntry: Void, info: GraphQLResolveInfo) { - dependentKeys.insert(joined(path: info.cachePath)) - } - - func accept(fieldEntries: [Void], info: GraphQLResolveInfo) { - } - - func finish(rootValue: Void, info: GraphQLResolveInfo) -> Set { - return dependentKeys - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLError.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLError.swift deleted file mode 100644 index 7480bb8..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLError.swift +++ /dev/null @@ -1,62 +0,0 @@ -import Foundation - -/// Represents an error encountered during the execution of a GraphQL operation. -/// -/// - SeeAlso: [The Response Format section in the GraphQL specification](https://facebook.github.io/graphql/#sec-Response-Format) -public struct GraphQLError: Error { - private let object: JSONObject - - public init(_ object: JSONObject) { - self.object = object - } - - init(_ message: String) { - self.init(["message": message]) - } - - /// GraphQL servers may provide additional entries as they choose to produce more helpful or machine‐readable errors. - public subscript(key: String) -> Any? { - return object[key] - } - - /// A description of the error. - public var message: String? { - return self["message"] as? String - } - - /// A list of locations in the requested GraphQL document associated with the error. - public var locations: [Location]? { - return (self["locations"] as? [JSONObject])?.compactMap(Location.init) - } - - /// A map which services can use however they see fit to provide additional information in errors to clients. - public var extensions: [String : Any]? { - return self["extensions"] as? [String : Any] - } - - /// Represents a location in a GraphQL document. - public struct Location { - /// The line number of a syntax element. - public let line: Int - /// The column number of a syntax element. - public let column: Int - - init?(_ object: JSONObject) { - guard let line = object["line"] as? Int, let column = object["column"] as? Int else { return nil } - self.line = line - self.column = column - } - } -} - -extension GraphQLError: CustomStringConvertible { - public var description: String { - return self.message ?? "GraphQL Error" - } -} - -extension GraphQLError: LocalizedError { - public var errorDescription: String? { - return description - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLExecutor.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLExecutor.swift deleted file mode 100644 index 966b20a..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLExecutor.swift +++ /dev/null @@ -1,286 +0,0 @@ -import Foundation -import Dispatch - -/// A resolver is responsible for resolving a value for a field. -public typealias GraphQLResolver = (_ object: JSONObject, _ info: GraphQLResolveInfo) -> ResultOrPromise - -public struct GraphQLResolveInfo { - let variables: GraphQLMap? - - var responsePath: [String] = [] - var responseKeyForField: String = "" - - var cachePath: [String] = [] - var cacheKeyForField: String = "" - - var fields: [GraphQLField] = [] - - init(rootKey: CacheKey?, variables: GraphQLMap?) { - self.variables = variables - - if let rootKey = rootKey { - cachePath = [rootKey] - } - } -} - -func joined(path: [String]) -> String { - return path.joined(separator: ".") -} - -public struct GraphQLResultError: Error, LocalizedError { - let path: [String] - let underlying: Error - - public var errorDescription: String? { - return "Error at path \"\(joined(path: path))\": \(underlying)" - } -} - -/// A GraphQL executor is responsible for executing a selection set and generating a result. It is initialized with a resolver closure that gets called repeatedly to resolve field values. -/// -/// An executor is used both to parse a response received from the server, and to read from the normalized cache. It can also be configured with a accumulator that receives events during execution, and these execution events are used by `GraphQLResultNormalizer` to normalize a response into a flat set of records and keep track of dependent keys. -/// -/// The methods in this class closely follow the [execution algorithm described in the GraphQL specification](https://facebook.github.io/graphql/#sec-Execution), but an important difference is that execution returns a value for every selection in a selection set, not the merged fields. This means we get a separate result for every fragment, even though all fields that share a response key are still executed at the same time for efficiency. -/// -/// So given the following query: -/// -/// ``` -/// query HeroAndFriendsNames { -/// hero { -/// name -/// friends { -/// name -/// } -/// ...FriendsAppearsIn -/// } -/// } -/// -/// fragment FriendsAppearsIn on Character { -/// friends { -/// appearsIn -/// } -/// } -/// ``` -/// -/// A server would return a response with `name` and `appearsIn` merged into one object: -/// -/// ``` -/// ... -/// { -/// "name": "R2-D2", -/// "friends": [ -/// { -/// "name": "Luke Skywalker", -/// "appearsIn": ["NEWHOPE", "EMPIRE", "JEDI"] -/// } -/// } -/// ... -/// ``` -/// -/// The executor on the other hand, will return a separate value for every selection: -/// -/// - `String` -/// - `[HeroAndFriendsNames.Data.Hero.Friend]` -/// - `FriendsAppearsIn` -/// - `[FriendsAppearsIn.Friend]` -/// -/// These values then get passed into a generated `GraphQLMappable` initializer, and this is how type safe results get built up. -/// -public final class GraphQLExecutor { - private let queue: DispatchQueue - - private let resolver: GraphQLResolver - var dispatchDataLoads: (() -> Void)? = nil - var dispatchDataLoadsScheduled: Bool = false - - var cacheKeyForObject: CacheKeyForObject? - var shouldComputeCachePath = true - - /// Creates a GraphQLExecutor that resolves field values by calling the provided resolver. - public init(resolver: @escaping GraphQLResolver) { - queue = DispatchQueue(label: "com.apollographql.GraphQLExecutor") - - self.resolver = resolver - } - - private func runtimeType(of object: JSONObject) -> String? { - return object["__typename"] as? String - } - - private func cacheKey(for object: JSONObject) -> String? { - guard let value = cacheKeyForObject?(object) else { return nil } - - if let array = value as? [Any?] { - return array.compactMap { String(describing: $0) }.joined(separator: "_") - } else { - return String(describing: value) - } - } - - // MARK: - Execution - - func execute(selections: [GraphQLSelection], on object: JSONObject, withKey key: CacheKey? = nil, variables: GraphQLMap? = nil, accumulator: Accumulator) throws -> Promise { - let info = GraphQLResolveInfo(rootKey: key, variables: variables) - - return try execute(selections: selections, on: object, info: info, accumulator: accumulator).map { - try accumulator.finish(rootValue: $0, info: info) - }.asPromise() - } - - private func execute(selections: [GraphQLSelection], on object: JSONObject, info: GraphQLResolveInfo, accumulator: Accumulator) throws -> ResultOrPromise { - var groupedFields = GroupedSequence() - try collectFields(selections: selections, forRuntimeType: runtimeType(of: object), into: &groupedFields, info: info) - - var fieldEntries: [ResultOrPromise] = [] - fieldEntries.reserveCapacity(groupedFields.keys.count) - - for (_, fields) in groupedFields { - let fieldEntry = try execute(fields: fields, on: object, info: info, accumulator: accumulator) - fieldEntries.append(fieldEntry) - } - - if let dispatchDataLoads = dispatchDataLoads, !dispatchDataLoadsScheduled { - dispatchDataLoadsScheduled = true - - queue.async { - self.dispatchDataLoadsScheduled = false - dispatchDataLoads() - } - } - - return whenAll(fieldEntries, notifyOn: queue).map { - try accumulator.accept(fieldEntries: $0, info: info) - } - } - - /// Before execution, the selection set is converted to a grouped field set. Each entry in the grouped field set is a list of fields that share a response key. This ensures all fields with the same response key (alias or field name) included via referenced fragments are executed at the same time. - private func collectFields(selections: [GraphQLSelection], forRuntimeType runtimeType: String?, into groupedFields: inout GroupedSequence, info: GraphQLResolveInfo) throws { - for selection in selections { - switch selection { - case let field as GraphQLField: - _ = groupedFields.append(value: field, forKey: field.responseKey) - case let booleanCondition as GraphQLBooleanCondition: - guard let value = info.variables?[booleanCondition.variableName] else { - throw GraphQLError("Variable \(booleanCondition.variableName) was not provided.") - } - if value as? Bool == !booleanCondition.inverted { - try collectFields(selections: booleanCondition.selections, forRuntimeType: runtimeType, into: &groupedFields, info: info) - } - case let fragmentSpread as GraphQLFragmentSpread: - let fragment = fragmentSpread.fragment - - if let runtimeType = runtimeType, fragment.possibleTypes.contains(runtimeType) { - try collectFields(selections: fragment.selections, forRuntimeType: runtimeType, into: &groupedFields, info: info) - } - case let typeCase as GraphQLTypeCase: - let selections: [GraphQLSelection] - if let runtimeType = runtimeType { - selections = typeCase.variants[runtimeType] ?? typeCase.default - } else { - selections = typeCase.default - } - try collectFields(selections: selections, forRuntimeType: runtimeType, into: &groupedFields, info: info) - default: - preconditionFailure() - } - } - } - - /// Each field requested in the grouped field set that is defined on the selected objectType will result in an entry in the response map. Field execution first coerces any provided argument values, then resolves a value for the field, and finally completes that value either by recursively executing another selection set or coercing a scalar value. - private func execute(fields: [GraphQLField], on object: JSONObject, info: GraphQLResolveInfo, accumulator: Accumulator) throws -> ResultOrPromise { - // GraphQL validation makes sure all fields sharing the same response key have the same arguments and are of the same type, so we only need to resolve one field. - let firstField = fields[0] - - var info = info - - let responseKey = firstField.responseKey - info.responseKeyForField = responseKey - info.responsePath.append(responseKey) - - if shouldComputeCachePath { - let cacheKey = try firstField.cacheKey(with: info.variables) - info.cacheKeyForField = cacheKey - info.cachePath.append(cacheKey) - } - - // We still need all fields to complete the value, because they may have different selection sets. - info.fields = fields - - let resultOrPromise = resolver(object, info) - - return resultOrPromise.on(queue: queue).flatMap { value in - guard let value = value else { - throw JSONDecodingError.missingValue - } - - return try self.complete(value: value, ofType: firstField.type, info: info, accumulator: accumulator) - }.map { - try accumulator.accept(fieldEntry: $0, info: info) - }.catch { error in - if !(error is GraphQLResultError) { - throw GraphQLResultError(path: info.responsePath, underlying: error) - } - } - } - - /// After resolving the value for a field, it is completed by ensuring it adheres to the expected return type. If the return type is another Object type, then the field execution process continues recursively. - private func complete(value: JSONValue, ofType returnType: GraphQLOutputType, info: GraphQLResolveInfo, accumulator: Accumulator) throws -> ResultOrPromise { - if case .nonNull(let innerType) = returnType { - if value is NSNull { - return .result(.failure(JSONDecodingError.nullValue)) - } - - return try complete(value: value, ofType: innerType, info: info, accumulator: accumulator) - } - - if value is NSNull { - return ResultOrPromise { try accumulator.acceptNullValue(info: info) } - } - - switch returnType { - case .scalar: - return ResultOrPromise { try accumulator.accept(scalar: value, info: info) } - case .list(let innerType): - guard let array = value as? [JSONValue] else { return .result(.failure(JSONDecodingError.wrongType)) } - - return try whenAll(array.enumerated().map { index, element -> ResultOrPromise in - var info = info - - let indexSegment = String(index) - info.responsePath.append(indexSegment) - info.cachePath.append(indexSegment) - - return try self.complete(value: element, ofType: innerType, info: info, accumulator: accumulator) - }, notifyOn: queue).map { completedArray in - return try accumulator.accept(list: completedArray, info: info) - } - case .object: - guard let object = value as? JSONObject else { return .result(.failure(JSONDecodingError.wrongType)) } - - // The merged selection set is a list of fields from all sub‐selection sets of the original fields. - let selections = mergeSelectionSets(for: info.fields) - - var info = info - if shouldComputeCachePath, let cacheKeyForObject = self.cacheKey(for: object) { - info.cachePath = [cacheKeyForObject] - } - - // We execute the merged selection set on the object to complete the value. This is the recursive step in the GraphQL execution model. - return try execute(selections: selections, on: object, info: info, accumulator: accumulator).map { return $0 as! Accumulator.PartialResult } - default: - preconditionFailure() - } - } - - /// When fields are selected multiple times, their selection sets are merged together when completing the value in order to continue execution of the sub‐selection sets. - private func mergeSelectionSets(for fields: [GraphQLField]) -> [GraphQLSelection] { - var selections: [GraphQLSelection] = [] - for field in fields { - if case let .object(fieldSelections) = field.type.namedType { - selections.append(contentsOf: fieldSelections) - } - } - return selections - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLInputValue.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLInputValue.swift deleted file mode 100644 index a2e2e72..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLInputValue.swift +++ /dev/null @@ -1,104 +0,0 @@ -import Foundation - -public protocol GraphQLInputValue { - func evaluate(with variables: [String: JSONEncodable]?) throws -> JSONValue -} - -public struct GraphQLVariable { - let name: String - - public init(_ name: String) { - self.name = name - } -} - -extension GraphQLVariable: GraphQLInputValue { - public func evaluate(with variables: [String: JSONEncodable]?) throws -> JSONValue { - guard let value = variables?[name] else { - throw GraphQLError("Variable \(name) was not provided.") - } - return value.jsonValue - } -} - -extension JSONEncodable { - public func evaluate(with variables: [String: JSONEncodable]?) throws -> JSONValue { - return jsonValue - } -} - -extension Dictionary: GraphQLInputValue { - public func evaluate(with variables: [String: JSONEncodable]?) throws -> JSONValue { - return try evaluate(with: variables) as JSONObject - } -} - -extension Dictionary { - public func evaluate(with variables: [String: JSONEncodable]?) throws -> JSONObject { - var jsonObject = JSONObject(minimumCapacity: count) - for (key, value) in self { - if case let (key as String, value as GraphQLInputValue) = (key, value) { - let evaluatedValue = try value.evaluate(with: variables) - if !(evaluatedValue is NSNull) { - jsonObject[key] = evaluatedValue - } - } else { - fatalError("Dictionary is only GraphQLInputValue if Value is (and if Key is String)") - } - } - return jsonObject - } -} - -extension Array: GraphQLInputValue { - public func evaluate(with variables: [String: JSONEncodable]?) throws -> JSONValue { - return try evaluate(with: variables) as [JSONValue] - } -} - -extension Array { - public func evaluate(with variables: [String: JSONEncodable]?) throws -> [JSONValue] { - var jsonArray = [JSONValue]() - jsonArray.reserveCapacity(count) - for (value) in self { - if case let (value as GraphQLInputValue) = value { - jsonArray.append(try value.evaluate(with: variables)) - } else { - fatalError("Array is only GraphQLInputValue if Element is") - } - } - return jsonArray - } -} - -public typealias GraphQLMap = [String: JSONEncodable?] - -extension Dictionary where Key == String, Value == JSONEncodable? { - public var withNilValuesRemoved: Dictionary { - var filtered = Dictionary(minimumCapacity: count) - for (key, value) in self { - if value != nil { - filtered[key] = value - } - } - return filtered - } -} - -public protocol GraphQLMapConvertible: JSONEncodable { - var graphQLMap: GraphQLMap { get } -} - -public extension GraphQLMapConvertible { - var jsonValue: JSONValue { - return graphQLMap.withNilValuesRemoved.jsonValue - } -} - -public extension GraphQLMapConvertible { - func evaluate(with variables: [String: JSONEncodable]?) throws -> JSONValue { - return try graphQLMap.evaluate(with: variables) - } -} - -public typealias GraphQLID = String diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLOperation.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLOperation.swift deleted file mode 100644 index 327b74e..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLOperation.swift +++ /dev/null @@ -1,52 +0,0 @@ -public enum GraphQLOperationType { - case query - case mutation - case subscription -} - -public protocol GraphQLOperation: class { - var operationType: GraphQLOperationType { get } - - var operationDefinition: String { get } - var operationIdentifier: String? { get } - - var queryDocument: String { get } - - var variables: GraphQLMap? { get } - - associatedtype Data: GraphQLSelectionSet -} - -public extension GraphQLOperation { - var queryDocument: String { - return operationDefinition - } - - var operationIdentifier: String? { - return nil - } - - var variables: GraphQLMap? { - return nil - } -} - -public protocol GraphQLQuery: GraphQLOperation {} -public extension GraphQLQuery { - var operationType: GraphQLOperationType { return .query } -} - -public protocol GraphQLMutation: GraphQLOperation {} -public extension GraphQLMutation { - var operationType: GraphQLOperationType { return .mutation } -} - -public protocol GraphQLSubscription: GraphQLOperation {} -public extension GraphQLSubscription { - var operationType: GraphQLOperationType { return .subscription } -} - -public protocol GraphQLFragment: GraphQLSelectionSet { - static var fragmentDefinition: String { get } - static var possibleTypes: [String] { get } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLQueryWatcher.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLQueryWatcher.swift deleted file mode 100644 index e515f97..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLQueryWatcher.swift +++ /dev/null @@ -1,54 +0,0 @@ -import Dispatch - -/// A `GraphQLQueryWatcher` is responsible for watching the store, and calling the result handler with a new result whenever any of the data the previous result depends on changes. -public final class GraphQLQueryWatcher: Cancellable, ApolloStoreSubscriber { - weak var client: ApolloClient? - let query: Query - let handlerQueue: DispatchQueue - let resultHandler: OperationResultHandler - - private var context = 0 - - private weak var fetching: Cancellable? - - private var dependentKeys: Set? - - init(client: ApolloClient, query: Query, handlerQueue: DispatchQueue, resultHandler: @escaping OperationResultHandler) { - self.client = client - self.query = query - self.handlerQueue = handlerQueue - self.resultHandler = resultHandler - - client.store.subscribe(self) - } - - /// Refetch a query from the server. - public func refetch() { - fetch(cachePolicy: .fetchIgnoringCacheData) - } - - func fetch(cachePolicy: CachePolicy) { - fetching = client?._fetch(query: query, cachePolicy: cachePolicy, context: &context, queue: handlerQueue) { [weak self] (result, error) in - guard let `self` = self else { return } - - self.dependentKeys = result?.dependentKeys - self.resultHandler(result, error) - } - } - - /// Cancel any in progress fetching operations and unsubscribe from the store. - public func cancel() { - fetching?.cancel() - client?.store.unsubscribe(self) - } - - func store(_ store: ApolloStore, didChangeKeys changedKeys: Set, context: UnsafeMutableRawPointer?) { - if context == &self.context { return } - - guard let dependentKeys = dependentKeys else { return } - - if !dependentKeys.isDisjoint(with: changedKeys) { - fetch(cachePolicy: .returnCacheDataElseFetch) - } - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLResponse.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLResponse.swift deleted file mode 100644 index 8a01d8a..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLResponse.swift +++ /dev/null @@ -1,40 +0,0 @@ -/// Represents a GraphQL response received from a server. -public final class GraphQLResponse { - public let operation: Operation - public let body: JSONObject - - public init(operation: Operation, body: JSONObject) { - self.operation = operation - self.body = body - } - - func parseResult(cacheKeyForObject: CacheKeyForObject? = nil) throws -> Promise<(GraphQLResult, RecordSet?)> { - let errors: [GraphQLError]? - - if let errorsEntry = body["errors"] as? [JSONObject] { - errors = errorsEntry.map(GraphQLError.init) - } else { - errors = nil - } - - if let dataEntry = body["data"] as? JSONObject { - let executor = GraphQLExecutor { object, info in - return .result(.success(object[info.responseKeyForField])) - } - - executor.cacheKeyForObject = cacheKeyForObject - - let mapper = GraphQLSelectionSetMapper() - let normalizer = GraphQLResultNormalizer() - let dependencyTracker = GraphQLDependencyTracker() - - return firstly { - try executor.execute(selections: Operation.Data.selections, on: dataEntry, withKey: rootCacheKey(for: operation), variables: operation.variables, accumulator: zip(mapper, normalizer, dependencyTracker)) - }.map { (data, records, dependentKeys) in - (GraphQLResult(data: data, errors: errors, source: .server, dependentKeys: dependentKeys), records) - } - } else { - return Promise(fulfilled: (GraphQLResult(data: nil, errors: errors, source: .server, dependentKeys: nil), nil)) - } - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLResponseGenerator.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLResponseGenerator.swift deleted file mode 100644 index 19283cb..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLResponseGenerator.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Foundation - -final class GraphQLResponseGenerator: GraphQLResultAccumulator { - func accept(scalar: JSONValue, info: GraphQLResolveInfo) -> JSONValue { - return scalar - } - - func acceptNullValue(info: GraphQLResolveInfo) -> JSONValue { - return NSNull() - } - - func accept(list: [JSONValue], info: GraphQLResolveInfo) -> JSONValue { - return list - } - - func accept(fieldEntry: JSONValue, info: GraphQLResolveInfo) -> (key: String, value: JSONValue) { - return (info.responseKeyForField, fieldEntry) - } - - func accept(fieldEntries: [(key: String, value: JSONValue)], info: GraphQLResolveInfo) -> JSONValue { - return JSONObject(fieldEntries) - } - - func finish(rootValue: JSONValue, info: GraphQLResolveInfo) throws -> JSONObject { - return rootValue as! JSONObject - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLResult.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLResult.swift deleted file mode 100644 index ce28e88..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLResult.swift +++ /dev/null @@ -1,25 +0,0 @@ -/// Represents the result of a GraphQL operation. -public struct GraphQLResult { - /// The typed result data, or `nil` if an error was encountered that prevented a valid response. - public let data: Data? - /// A list of errors, or `nil` if the operation completed without encountering any errors. - public let errors: [GraphQLError]? - - /// Represents source of data - public enum Source { - case cache - case server - } - /// Source of data - public let source: Source - - let dependentKeys: Set? - - init(data: Data?, errors: [GraphQLError]?, source: Source, dependentKeys: Set?) { - self.data = data - self.errors = errors - self.source = source - self.dependentKeys = dependentKeys - } -} - diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLResultAccumulator.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLResultAccumulator.swift deleted file mode 100644 index b79a2fe..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLResultAccumulator.swift +++ /dev/null @@ -1,108 +0,0 @@ -public protocol GraphQLResultAccumulator: class { - associatedtype PartialResult - associatedtype FieldEntry - associatedtype ObjectResult - associatedtype FinalResult - - func accept(scalar: JSONValue, info: GraphQLResolveInfo) throws -> PartialResult - func acceptNullValue(info: GraphQLResolveInfo) throws -> PartialResult - func accept(list: [PartialResult], info: GraphQLResolveInfo) throws -> PartialResult - - func accept(fieldEntry: PartialResult, info: GraphQLResolveInfo) throws -> FieldEntry - func accept(fieldEntries: [FieldEntry], info: GraphQLResolveInfo) throws -> ObjectResult - - func finish(rootValue: ObjectResult, info: GraphQLResolveInfo) throws -> FinalResult -} - -public func zip(_ accumulator1: Accumulator1, _ accumulator2: Accumulator2) -> Zip2Accumulator { - return Zip2Accumulator(accumulator1, accumulator2) -} - -public func zip(_ accumulator1: Accumulator1, _ accumulator2: Accumulator2, _ accumulator3: Accumulator3) -> Zip3Accumulator { - return Zip3Accumulator(accumulator1, accumulator2, accumulator3) -} - -public final class Zip2Accumulator: GraphQLResultAccumulator { - public typealias PartialResult = (Accumulator1.PartialResult, Accumulator2.PartialResult) - public typealias FieldEntry = (Accumulator1.FieldEntry, Accumulator2.FieldEntry) - public typealias ObjectResult = (Accumulator1.ObjectResult, Accumulator2.ObjectResult) - public typealias FinalResult = (Accumulator1.FinalResult, Accumulator2.FinalResult) - - private let accumulator1: Accumulator1 - private let accumulator2: Accumulator2 - - fileprivate init(_ accumulator1: Accumulator1, _ accumulator2: Accumulator2) { - self.accumulator1 = accumulator1 - self.accumulator2 = accumulator2 - } - - public func accept(scalar: JSONValue, info: GraphQLResolveInfo) throws -> PartialResult { - return (try accumulator1.accept(scalar: scalar, info: info), try accumulator2.accept(scalar: scalar, info: info)) - } - - public func acceptNullValue(info: GraphQLResolveInfo) throws -> PartialResult { - return (try accumulator1.acceptNullValue(info: info), try accumulator2.acceptNullValue(info: info)) - } - - public func accept(list: [PartialResult], info: GraphQLResolveInfo) throws -> PartialResult { - let (list1, list2) = unzip(list) - return (try accumulator1.accept(list: list1, info: info), try accumulator2.accept(list: list2, info: info)) - } - - public func accept(fieldEntry: PartialResult, info: GraphQLResolveInfo) throws -> FieldEntry { - return (try accumulator1.accept(fieldEntry: fieldEntry.0, info: info), try accumulator2.accept(fieldEntry: fieldEntry.1, info: info)) - } - - public func accept(fieldEntries: [FieldEntry], info: GraphQLResolveInfo) throws -> ObjectResult { - let (fieldEntries1, fieldEntries2) = unzip(fieldEntries) - return (try accumulator1.accept(fieldEntries: fieldEntries1, info: info), try accumulator2.accept(fieldEntries: fieldEntries2, info: info)) - } - - public func finish(rootValue: ObjectResult, info: GraphQLResolveInfo) throws -> FinalResult { - return (try accumulator1.finish(rootValue: rootValue.0, info: info), try accumulator2.finish(rootValue: rootValue.1, info: info)) - } -} - -public final class Zip3Accumulator: GraphQLResultAccumulator { - public typealias PartialResult = (Accumulator1.PartialResult, Accumulator2.PartialResult, Accumulator3.PartialResult) - public typealias FieldEntry = (Accumulator1.FieldEntry, Accumulator2.FieldEntry, Accumulator3.FieldEntry) - public typealias ObjectResult = (Accumulator1.ObjectResult, Accumulator2.ObjectResult, Accumulator3.ObjectResult) - public typealias FinalResult = (Accumulator1.FinalResult, Accumulator2.FinalResult, Accumulator3.FinalResult) - - private let accumulator1: Accumulator1 - private let accumulator2: Accumulator2 - private let accumulator3: Accumulator3 - - - fileprivate init(_ accumulator1: Accumulator1, _ accumulator2: Accumulator2, _ accumulator3: Accumulator3) { - self.accumulator1 = accumulator1 - self.accumulator2 = accumulator2 - self.accumulator3 = accumulator3 - } - - public func accept(scalar: JSONValue, info: GraphQLResolveInfo) throws -> PartialResult { - return (try accumulator1.accept(scalar: scalar, info: info), try accumulator2.accept(scalar: scalar, info: info), try accumulator3.accept(scalar: scalar, info: info)) - } - - public func acceptNullValue(info: GraphQLResolveInfo) throws -> PartialResult { - return (try accumulator1.acceptNullValue(info: info), try accumulator2.acceptNullValue(info: info), try accumulator3.acceptNullValue(info: info)) - } - - public func accept(list: [PartialResult], info: GraphQLResolveInfo) throws -> PartialResult { - let (list1, list2, list3) = unzip(list) - return (try accumulator1.accept(list: list1, info: info), try accumulator2.accept(list: list2, info: info), try accumulator3.accept(list: list3, info: info)) - } - - public func accept(fieldEntry: PartialResult, info: GraphQLResolveInfo) throws -> FieldEntry { - return (try accumulator1.accept(fieldEntry: fieldEntry.0, info: info), try accumulator2.accept(fieldEntry: fieldEntry.1, info: info), try accumulator3.accept(fieldEntry: fieldEntry.2, info: info)) - } - - public func accept(fieldEntries: [FieldEntry], info: GraphQLResolveInfo) throws -> ObjectResult { - let (fieldEntries1, fieldEntries2, fieldEntries3) = unzip(fieldEntries) - return (try accumulator1.accept(fieldEntries: fieldEntries1, info: info), try accumulator2.accept(fieldEntries: fieldEntries2, info: info), try accumulator3.accept(fieldEntries: fieldEntries3, info: info)) - } - - public func finish(rootValue: ObjectResult, info: GraphQLResolveInfo) throws -> FinalResult { - return (try accumulator1.finish(rootValue: rootValue.0, info: info), try accumulator2.finish(rootValue: rootValue.1, info: info), try accumulator3.finish(rootValue: rootValue.2, info: info)) - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLResultNormalizer.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLResultNormalizer.swift deleted file mode 100644 index 1878968..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLResultNormalizer.swift +++ /dev/null @@ -1,34 +0,0 @@ -import Foundation - -final class GraphQLResultNormalizer: GraphQLResultAccumulator { - private var records: RecordSet = [:] - - func accept(scalar: JSONValue, info: GraphQLResolveInfo) -> JSONValue { - return scalar - } - - func acceptNullValue(info: GraphQLResolveInfo) -> JSONValue { - return NSNull() - } - - func accept(list: [JSONValue], info: GraphQLResolveInfo) -> JSONValue { - return list - } - - func accept(fieldEntry: JSONValue, info: GraphQLResolveInfo) -> (key: String, value: JSONValue) { - return (info.cacheKeyForField, fieldEntry) - } - - func accept(fieldEntries: [(key: String, value: JSONValue)], info: GraphQLResolveInfo) throws -> JSONValue { - let cachePath = joined(path: info.cachePath) - - let object = JSONObject(fieldEntries) - records.merge(record: Record(key: cachePath, object)) - - return Reference(key: cachePath) - } - - func finish(rootValue: JSONValue, info: GraphQLResolveInfo) throws -> RecordSet { - return records - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLSelectionSet.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLSelectionSet.swift deleted file mode 100644 index 6be1219..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLSelectionSet.swift +++ /dev/null @@ -1,128 +0,0 @@ -public typealias ResultMap = [String: Any?] - -public protocol GraphQLSelectionSet { - static var selections: [GraphQLSelection] { get } - - var resultMap: ResultMap { get } - init(unsafeResultMap: ResultMap) -} - -public extension GraphQLSelectionSet { - init(jsonObject: JSONObject, variables: GraphQLMap? = nil) throws { - let executor = GraphQLExecutor { object, info in - .result(.success(object[info.responseKeyForField])) - } - executor.shouldComputeCachePath = false - self = try executor.execute(selections: Self.selections, on: jsonObject, variables: variables, accumulator: GraphQLSelectionSetMapper()).await() - } - - var jsonObject: JSONObject { - return resultMap.jsonObject - } -} - -extension GraphQLSelectionSet { - public init(_ selectionSet: GraphQLSelectionSet) throws { - try self.init(jsonObject: selectionSet.jsonObject) - } -} - -public protocol GraphQLSelection { -} - -public struct GraphQLField: GraphQLSelection { - let name: String - let alias: String? - let arguments: [String: GraphQLInputValue]? - - var responseKey: String { - return alias ?? name - } - - let type: GraphQLOutputType - - public init(_ name: String, alias: String? = nil, arguments: [String: GraphQLInputValue]? = nil, type: GraphQLOutputType) { - self.name = name - self.alias = alias - - self.arguments = arguments - - self.type = type - } - - func cacheKey(with variables: [String: JSONEncodable]?) throws -> String { - if let argumentValues = try arguments?.evaluate(with: variables), !argumentValues.isEmpty { - let argumentsKey = orderIndependentKey(for: argumentValues) - return "\(name)(\(argumentsKey))" - } else { - return name - } - } -} - -public indirect enum GraphQLOutputType { - case scalar(JSONDecodable.Type) - case object([GraphQLSelection]) - case nonNull(GraphQLOutputType) - case list(GraphQLOutputType) - - var namedType: GraphQLOutputType { - switch self { - case .nonNull(let innerType), .list(let innerType): - return innerType.namedType - case .scalar, .object: - return self - } - } -} - -private func orderIndependentKey(for object: JSONObject) -> String { - return object.sorted { $0.key < $1.key }.map { - if let object = $0.value as? JSONObject { - return "[\($0.key):\(orderIndependentKey(for: object))]" - } else { - return "\($0.key):\($0.value)" - } - }.joined(separator: ",") -} - -public struct GraphQLBooleanCondition: GraphQLSelection { - let variableName: String - let inverted: Bool - let selections: [GraphQLSelection] - - public init(variableName: String, inverted: Bool, selections: [GraphQLSelection]) { - self.variableName = variableName - self.inverted = inverted; - self.selections = selections; - } -} - -public struct GraphQLTypeCondition: GraphQLSelection { - let possibleTypes: [String] - let selections: [GraphQLSelection] - - public init(possibleTypes: [String], selections: [GraphQLSelection]) { - self.possibleTypes = possibleTypes - self.selections = selections; - } -} - -public struct GraphQLFragmentSpread: GraphQLSelection { - let fragment: GraphQLFragment.Type - - public init(_ fragment: GraphQLFragment.Type) { - self.fragment = fragment - } -} - -public struct GraphQLTypeCase: GraphQLSelection { - let variants: [String: [GraphQLSelection]] - let `default`: [GraphQLSelection] - - public init(variants: [String: [GraphQLSelection]], default: [GraphQLSelection]) { - self.variants = variants - self.default = `default`; - } -} - diff --git a/Example/Pods/Apollo/Sources/Apollo/GraphQLSelectionSetMapper.swift b/Example/Pods/Apollo/Sources/Apollo/GraphQLSelectionSetMapper.swift deleted file mode 100644 index cee0293..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/GraphQLSelectionSetMapper.swift +++ /dev/null @@ -1,27 +0,0 @@ -final class GraphQLSelectionSetMapper: GraphQLResultAccumulator { - func accept(scalar: JSONValue, info: GraphQLResolveInfo) throws -> Any? { - guard case .scalar(let decodable) = info.fields[0].type.namedType else { preconditionFailure() } - // This will convert a JSON value to the expected value type, which could be a custom scalar or an enum. - return try decodable.init(jsonValue: scalar) - } - - func acceptNullValue(info: GraphQLResolveInfo) -> Any? { - return nil - } - - func accept(list: [Any?], info: GraphQLResolveInfo) -> Any? { - return list - } - - func accept(fieldEntry: Any?, info: GraphQLResolveInfo) -> (key: String, value: Any?) { - return (info.responseKeyForField, fieldEntry) - } - - func accept(fieldEntries: [(key: String, value: Any?)], info: GraphQLResolveInfo) throws -> ResultMap { - return ResultMap(fieldEntries) - } - - func finish(rootValue: ResultMap, info: GraphQLResolveInfo) -> SelectionSet { - return SelectionSet.init(unsafeResultMap: rootValue) - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/HTTPNetworkTransport.swift b/Example/Pods/Apollo/Sources/Apollo/HTTPNetworkTransport.swift deleted file mode 100644 index ac3cc54..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/HTTPNetworkTransport.swift +++ /dev/null @@ -1,132 +0,0 @@ -import Foundation - -extension URLSessionTask: Cancellable {} - -/// A transport-level, HTTP-specific error. -public struct GraphQLHTTPResponseError: Error, LocalizedError { - public enum ErrorKind { - case errorResponse - case invalidResponse - - var description: String { - switch self { - case .errorResponse: - return "Received error response" - case .invalidResponse: - return "Received invalid response" - } - } - } - - /// The body of the response. - public let body: Data? - /// Information about the response as provided by the server. - public let response: HTTPURLResponse - public let kind: ErrorKind - - public init(body: Data? = nil, response: HTTPURLResponse, kind: ErrorKind) { - self.body = body - self.response = response - self.kind = kind - } - - public var bodyDescription: String { - if let body = body { - if let description = String(data: body, encoding: response.textEncoding ?? .utf8) { - return description - } else { - return "Unreadable response body" - } - } else { - return "Empty response body" - } - } - - public var errorDescription: String? { - return "\(kind.description) (\(response.statusCode) \(response.statusCodeDescription)): \(bodyDescription)" - } -} - -/// A network transport that uses HTTP POST requests to send GraphQL operations to a server, and that uses `URLSession` as the networking implementation. -public class HTTPNetworkTransport: NetworkTransport { - let url: URL - let session: URLSession - let serializationFormat = JSONSerializationFormat.self - - /// Creates a network transport with the specified server URL and session configuration. - /// - /// - Parameters: - /// - url: The URL of a GraphQL server to connect to. - /// - configuration: A session configuration used to configure the session. Defaults to `URLSessionConfiguration.default`. - /// - sendOperationIdentifiers: Whether to send operation identifiers rather than full operation text, for use with servers that support query persistence. Defaults to false. - public init(url: URL, configuration: URLSessionConfiguration = URLSessionConfiguration.default, sendOperationIdentifiers: Bool = false) { - self.url = url - self.session = URLSession(configuration: configuration) - self.sendOperationIdentifiers = sendOperationIdentifiers - } - - /// Send a GraphQL operation to a server and return a response. - /// - /// - Parameters: - /// - operation: The operation to send. - /// - completionHandler: A closure to call when a request completes. - /// - response: The response received from the server, or `nil` if an error occurred. - /// - error: An error that indicates why a request failed, or `nil` if the request was succesful. - /// - Returns: An object that can be used to cancel an in progress request. - public func send(operation: Operation, completionHandler: @escaping (_ response: GraphQLResponse?, _ error: Error?) -> Void) -> Cancellable { - var request = URLRequest(url: url) - request.httpMethod = "POST" - - request.setValue("application/json", forHTTPHeaderField: "Content-Type") - - let body = requestBody(for: operation) - request.httpBody = try! serializationFormat.serialize(value: body) - - let task = session.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Error?) in - if error != nil { - completionHandler(nil, error) - return - } - - guard let httpResponse = response as? HTTPURLResponse else { - fatalError("Response should be an HTTPURLResponse") - } - - if (!httpResponse.isSuccessful) { - completionHandler(nil, GraphQLHTTPResponseError(body: data, response: httpResponse, kind: .errorResponse)) - return - } - - guard let data = data else { - completionHandler(nil, GraphQLHTTPResponseError(body: nil, response: httpResponse, kind: .invalidResponse)) - return - } - - do { - guard let body = try self.serializationFormat.deserialize(data: data) as? JSONObject else { - throw GraphQLHTTPResponseError(body: data, response: httpResponse, kind: .invalidResponse) - } - let response = GraphQLResponse(operation: operation, body: body) - completionHandler(response, nil) - } catch { - completionHandler(nil, error) - } - } - - task.resume() - - return task - } - - private let sendOperationIdentifiers: Bool - - private func requestBody(for operation: Operation) -> GraphQLMap { - if sendOperationIdentifiers { - guard let operationIdentifier = operation.operationIdentifier else { - preconditionFailure("To send operation identifiers, Apollo types must be generated with operationIdentifiers") - } - return ["id": operationIdentifier, "variables": operation.variables] - } - return ["query": operation.queryDocument, "variables": operation.variables] - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/InMemoryNormalizedCache.swift b/Example/Pods/Apollo/Sources/Apollo/InMemoryNormalizedCache.swift deleted file mode 100644 index 1576833..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/InMemoryNormalizedCache.swift +++ /dev/null @@ -1,21 +0,0 @@ -public final class InMemoryNormalizedCache: NormalizedCache { - private var records: RecordSet - - public init(records: RecordSet = RecordSet()) { - self.records = records - } - - public func loadRecords(forKeys keys: [CacheKey]) -> Promise<[Record?]> { - let records = keys.map { self.records[$0] } - return Promise(fulfilled: records) - } - - public func merge(records: RecordSet) -> Promise> { - return Promise(fulfilled: self.records.merge(records: records)) - } - - public func clear() -> Promise { - records.clear() - return Promise(fulfilled: ()) - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/JSON.swift b/Example/Pods/Apollo/Sources/Apollo/JSON.swift deleted file mode 100644 index ae629ed..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/JSON.swift +++ /dev/null @@ -1,60 +0,0 @@ -import Foundation - -public typealias JSONValue = Any - -public typealias JSONObject = [String: JSONValue] - -public protocol JSONDecodable { - init(jsonValue value: JSONValue) throws -} - -public protocol JSONEncodable: GraphQLInputValue { - var jsonValue: JSONValue { get } -} - -public enum JSONDecodingError: Error, LocalizedError { - case missingValue - case nullValue - case wrongType - case couldNotConvert(value: Any, to: Any.Type) - - public var errorDescription: String? { - switch self { - case .missingValue: - return "Missing value" - case .nullValue: - return "Unexpected null value" - case .wrongType: - return "Wrong type" - case .couldNotConvert(let value, let expectedType): - return "Could not convert \"\(value)\" to \(expectedType)" - } - } -} - -extension JSONDecodingError: Matchable { - public typealias Base = Error - public static func ~=(pattern: JSONDecodingError, value: Error) -> Bool { - guard let value = value as? JSONDecodingError else { - return false - } - - switch (value, pattern) { - case (.missingValue, .missingValue), (.nullValue, .nullValue), (.wrongType, .wrongType), (.couldNotConvert, .couldNotConvert): - return true - default: - return false - } - } -} - -// MARK: Helpers - -func equals(_ lhs: Any, _ rhs: Any) -> Bool { - if let lhs = lhs as? Reference, let rhs = rhs as? Reference { - return lhs == rhs - } - - let lhs = lhs as AnyObject, rhs = rhs as AnyObject - return lhs.isEqual(rhs) -} diff --git a/Example/Pods/Apollo/Sources/Apollo/JSONSerializationFormat.swift b/Example/Pods/Apollo/Sources/Apollo/JSONSerializationFormat.swift deleted file mode 100644 index fe4d9bc..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/JSONSerializationFormat.swift +++ /dev/null @@ -1,11 +0,0 @@ -import Foundation - -public final class JSONSerializationFormat { - public class func serialize(value: JSONEncodable) throws -> Data { - return try JSONSerialization.data(withJSONObject: value.jsonValue, options: []) - } - - public class func deserialize(data: Data) throws -> JSONValue { - return try JSONSerialization.jsonObject(with: data, options: []) - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/JSONStandardTypeConversions.swift b/Example/Pods/Apollo/Sources/Apollo/JSONStandardTypeConversions.swift deleted file mode 100644 index 0122254..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/JSONStandardTypeConversions.swift +++ /dev/null @@ -1,158 +0,0 @@ -import Foundation - -extension String: JSONDecodable, JSONEncodable { - public init(jsonValue value: JSONValue) throws { - guard let string = value as? String else { - throw JSONDecodingError.couldNotConvert(value: value, to: String.self) - } - self = string - } - - public var jsonValue: JSONValue { - return self - } -} - -extension Int: JSONDecodable, JSONEncodable { - public init(jsonValue value: JSONValue) throws { - guard let number = value as? NSNumber else { - throw JSONDecodingError.couldNotConvert(value: value, to: Int.self) - } - self = number.intValue - } - - public var jsonValue: JSONValue { - return self - } -} - -extension Float: JSONDecodable, JSONEncodable { - public init(jsonValue value: JSONValue) throws { - guard let number = value as? NSNumber else { - throw JSONDecodingError.couldNotConvert(value: value, to: Float.self) - } - self = number.floatValue - } - - public var jsonValue: JSONValue { - return self - } -} - -extension Double: JSONDecodable, JSONEncodable { - public init(jsonValue value: JSONValue) throws { - guard let number = value as? NSNumber else { - throw JSONDecodingError.couldNotConvert(value: value, to: Double.self) - } - self = number.doubleValue - } - - public var jsonValue: JSONValue { - return self - } -} - -extension Bool: JSONDecodable, JSONEncodable { - public init(jsonValue value: JSONValue) throws { - guard let bool = value as? Bool else { - throw JSONDecodingError.couldNotConvert(value: value, to: Bool.self) - } - self = bool - } - - public var jsonValue: JSONValue { - return self - } -} - -extension RawRepresentable where RawValue: JSONDecodable { - public init(jsonValue value: JSONValue) throws { - let rawValue = try RawValue(jsonValue: value) - if let tempSelf = Self(rawValue: rawValue) { - self = tempSelf - } else { - throw JSONDecodingError.couldNotConvert(value: value, to: Self.self) - } - } -} - -extension RawRepresentable where RawValue: JSONEncodable { - public var jsonValue: JSONValue { - return rawValue.jsonValue - } -} - -extension Optional where Wrapped: JSONDecodable { - public init(jsonValue value: JSONValue) throws { - if value is NSNull { - self = .none - } else { - self = .some(try Wrapped(jsonValue: value)) - } - } -} - -// Once [conditional conformances](https://github.com/apple/swift-evolution/blob/master/proposals/0143-conditional-conformances.md) have been implemented, we should be able to replace these runtime type checks with proper static typing - -extension Optional: JSONEncodable { - public var jsonValue: JSONValue { - switch self { - case .none: - return NSNull() - case .some(let wrapped as JSONEncodable): - return wrapped.jsonValue - default: - fatalError("Optional is only JSONEncodable if Wrapped is") - } - } -} - -extension Dictionary: JSONEncodable { - public var jsonValue: JSONValue { - return jsonObject - } - - public var jsonObject: JSONObject { - var jsonObject = JSONObject(minimumCapacity: count) - for (key, value) in self { - if case let (key as String, value as JSONEncodable) = (key, value) { - jsonObject[key] = value.jsonValue - } else { - fatalError("Dictionary is only JSONEncodable if Value is (and if Key is String)") - } - } - return jsonObject - } -} - -extension Array: JSONEncodable { - public var jsonValue: JSONValue { - return map() { element -> (JSONValue) in - if case let element as JSONEncodable = element { - return element.jsonValue - } else { - fatalError("Array is only JSONEncodable if Element is") - } - } - } -} - -// Example custom scalar - -extension URL: JSONDecodable, JSONEncodable { - public init(jsonValue value: JSONValue) throws { - guard let string = value as? String else { - throw JSONDecodingError.couldNotConvert(value: value, to: URL.self) - } - - if let url = URL(string: string) { - self = url - } else { - throw JSONDecodingError.couldNotConvert(value: value, to: URL.self) - } - } - - public var jsonValue: JSONValue { - return self.absoluteString - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/Locking.swift b/Example/Pods/Apollo/Sources/Apollo/Locking.swift deleted file mode 100644 index cad7db5..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/Locking.swift +++ /dev/null @@ -1,69 +0,0 @@ -import Foundation - -final class Mutex { - private var _lock = pthread_mutex_t() - - init() { - let result = pthread_mutex_init(&_lock, nil) - assert(result == 0) - } - - deinit { - let result = pthread_mutex_destroy(&_lock) - assert(result == 0) - } - - func lock() { - let result = pthread_mutex_lock(&_lock) - assert(result == 0) - } - - func unlock() { - let result = pthread_mutex_unlock(&_lock) - assert(result == 0) - } - - func withLock(_ body: () throws -> T) rethrows -> T { - lock() - defer { unlock() } - return try body() - } -} - -final class ReadWriteLock { - private var _lock = pthread_rwlock_t() - - init() { - let status = pthread_rwlock_init(&_lock, nil) - assert(status == 0) - } - - deinit { - let status = pthread_rwlock_destroy(&_lock) - assert(status == 0) - } - - func lockForReading() { - pthread_rwlock_rdlock(&_lock) - } - - func lockForWriting() { - pthread_rwlock_wrlock(&_lock) - } - - func unlock() { - pthread_rwlock_unlock(&_lock) - } - - func withReadLock(_ body: () throws -> T) rethrows -> T { - lockForReading() - defer { unlock() } - return try body() - } - - func withWriteLock(_ body: () throws -> T) rethrows -> T { - lockForWriting() - defer { unlock() } - return try body() - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/NetworkTransport.swift b/Example/Pods/Apollo/Sources/Apollo/NetworkTransport.swift deleted file mode 100644 index dbd80a8..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/NetworkTransport.swift +++ /dev/null @@ -1,13 +0,0 @@ -/// A network transport is responsible for sending GraphQL operations to a server. -public protocol NetworkTransport { - /// Send a GraphQL operation to a server and return a response. - /// - /// - Parameters: - /// - operation: The operation to send. - /// - completionHandler: A closure to call when a request completes. - /// - response: The response received from the server, or `nil` if an error occurred. - /// - error: An error that indicates why a request failed, or `nil` if the request was succesful. - /// - Returns: An object that can be used to cancel an in progress request. - func send(operation: Operation, completionHandler: @escaping (_ response: GraphQLResponse?, _ error: Error?) -> Void) -> Cancellable -} - diff --git a/Example/Pods/Apollo/Sources/Apollo/NormalizedCache.swift b/Example/Pods/Apollo/Sources/Apollo/NormalizedCache.swift deleted file mode 100644 index 180d5e9..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/NormalizedCache.swift +++ /dev/null @@ -1,16 +0,0 @@ -public protocol NormalizedCache { - - /// Loads records corresponding to the given keys. - /// - returns: A promise that fulfills with an array, with each index containing either the - /// record corresponding to the key at that index or nil if not found. - func loadRecords(forKeys keys: [CacheKey]) -> Promise<[Record?]> - - /// Merges a set of records into the cache. - /// - returns: A promise that fulfills with a set of keys corresponding to *fields* that have - /// changed (i.e. QUERY_ROOT.Foo.myField). These are the same type of keys as are - /// returned by RecordSet.merge(records:). - func merge(records: RecordSet) -> Promise> - - // Clears all records - func clear() -> Promise -} diff --git a/Example/Pods/Apollo/Sources/Apollo/Promise.swift b/Example/Pods/Apollo/Sources/Apollo/Promise.swift deleted file mode 100644 index 94f30e8..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/Promise.swift +++ /dev/null @@ -1,260 +0,0 @@ -import Dispatch - -public func whenAll(_ promises: [Promise], notifyOn queue: DispatchQueue = .global()) -> Promise<[Value]> { - return Promise { (fulfill, reject) in - let group = DispatchGroup() - - for promise in promises { - group.enter() - - promise.andThen { value in - group.leave() - }.catch { error in - reject(error) - } - } - - group.notify(queue: queue) { - fulfill(promises.map { $0.result!.value! }) - } - } -} - -public func firstly(_ body: () throws -> Promise) -> Promise { - do { - return try body() - } catch { - return Promise(rejected: error) - } -} - -public final class Promise { - private let lock = Mutex() - private var state: State - - private typealias ResultHandler = (Result) -> Void - private var resultHandlers: [ResultHandler] = [] - - public init(resolved result: Result) { - state = .resolved(result) - } - - public init(fulfilled value: Value) { - state = .resolved(.success(value)) - } - - public init(rejected error: Error) { - state = .resolved(.failure(error)) - } - - public init(_ body: () throws -> Value) { - do { - let value = try body() - state = .resolved(.success(value)) - } catch { - state = .resolved(.failure(error)) - } - } - - public init(_ body: (_ fulfill: @escaping (Value) -> Void, _ reject: @escaping (Error) -> Void) throws -> Void) { - state = .pending - - do { - try body(self.fulfill, self.reject) - } catch { - self.reject(error) - } - } - - public var isPending: Bool { - return lock.withLock { - state.isPending - } - } - - public var result: Result? { - return lock.withLock { - switch state { - case .pending: - return nil - case .resolved(let result): - return result - } - } - } - - public func wait() { - let semaphore = DispatchSemaphore(value: 0) - - whenResolved { result in - semaphore.signal() - } - - semaphore.wait() - } - - public func await() throws -> Value { - let semaphore = DispatchSemaphore(value: 0) - - var result: Result? = nil - - whenResolved { - result = $0 - semaphore.signal() - } - - semaphore.wait() - - return try result!.valueOrError() - } - - @discardableResult public func andThen(_ whenFulfilled: @escaping (Value) throws -> Void) -> Promise { - return Promise { fulfill, reject in - whenResolved { result in - switch result { - case .success(let value): - do { - try whenFulfilled(value) - fulfill(value) - } catch { - reject(error) - } - case .failure(let error): - reject(error) - } - } - } - } - - @discardableResult public func `catch`(_ whenRejected: @escaping (Error) throws -> Void) -> Promise { - return Promise { fulfill, reject in - whenResolved { result in - switch result { - case .success(let value): - fulfill(value) - case .failure(let error): - do { - try whenRejected(error) - reject(error) - } catch { - reject(error) - } - } - } - } - } - - @discardableResult public func finally(_ whenResolved: @escaping () -> Void) -> Promise { - self.whenResolved { _ in whenResolved() } - return self - } - - public func map(_ transform: @escaping (Value) throws -> T) -> Promise { - return Promise { fulfill, reject in - whenResolved { result in - switch result { - case .success(let value): - do { - fulfill(try transform(value)) - } catch { - reject(error) - } - case .failure(let error): - reject(error) - } - } - } - } - - public func flatMap(_ transform: @escaping (Value) throws -> Promise) -> Promise { - return Promise { fulfill, reject in - whenResolved { result in - switch result { - case .success(let value): - do { - try transform(value).andThen(fulfill).catch(reject) - } catch { - reject(error) - } - case .failure(let error): - reject(error) - } - } - } - } - - public func on(queue: DispatchQueue) -> Promise { - return Promise { fulfill, reject in - whenResolved { result in - switch result { - case .success(let value): - queue.async { - fulfill(value) - } - case .failure(let error): - queue.async { - reject(error) - } - } - } - } - } - - private func fulfill(_ value: Value) { - resolve(.success(value)) - } - - private func reject(_ error: Error) { - resolve(.failure(error)) - } - - private func resolve(_ result: Result) { - lock.withLock { - guard state.isPending else { return } - - state = .resolved(result) - - for handler in resultHandlers { - handler(result) - } - - resultHandlers = [] - } - } - - private func whenResolved(_ handler: @escaping ResultHandler) { - lock.withLock { - // If the promise has been resolved and there are no existing result handlers, - // there is no need to append the handler to the array first. - if case .resolved(let result) = state, resultHandlers.isEmpty { - handler(result) - } else { - resultHandlers.append(handler) - } - } - } -} - -private enum State { - case pending - case resolved(Result) - - var isPending: Bool { - if case .pending = self { - return true - } else { - return false - } - } -} - -extension State: CustomStringConvertible { - var description: String { - switch self { - case .pending: - return "Promise(Pending)" - case .resolved(let result): - return "Promise(\(result))" - } - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/Record.swift b/Example/Pods/Apollo/Sources/Apollo/Record.swift deleted file mode 100644 index f739718..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/Record.swift +++ /dev/null @@ -1,52 +0,0 @@ -/// A cache key for a record. -public typealias CacheKey = String - -/// A cache record. -public struct Record { - public let key: CacheKey - - public typealias Value = Any - public typealias Fields = [CacheKey: Value] - public private(set) var fields: Fields - - public init(key: CacheKey, _ fields: Fields = [:]) { - self.key = key - self.fields = fields - } - - public subscript(key: CacheKey) -> Value? { - get { - return fields[key] - } - set { - fields[key] = newValue - } - } -} - -extension Record: CustomStringConvertible { - public var description: String { - return "#\(key) -> \(fields)" - } -} - -/// A reference to a cache record. -public struct Reference { - public let key: CacheKey - - public init(key: CacheKey) { - self.key = key - } -} - -extension Reference: Equatable { - public static func ==(lhs: Reference, rhs: Reference) -> Bool { - return lhs.key == rhs.key - } -} - -extension Reference: CustomStringConvertible { - public var description: String { - return "-> #\(key)" - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/RecordSet.swift b/Example/Pods/Apollo/Sources/Apollo/RecordSet.swift deleted file mode 100644 index 8aff345..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/RecordSet.swift +++ /dev/null @@ -1,81 +0,0 @@ -/// A set of cache records. -public struct RecordSet { - public private(set) var storage: [CacheKey: Record] = [:] - - public init(records: S) where S.Iterator.Element == Record { - insert(contentsOf: records) - } - - public mutating func insert(_ record: Record) { - storage[record.key] = record - } - - public mutating func clear() { - storage.removeAll() - } - - public mutating func insert(contentsOf records: S) where S.Iterator.Element == Record { - for record in records { - insert(record) - } - } - - public subscript(key: CacheKey) -> Record? { - return storage[key] - } - - public var isEmpty: Bool { - return storage.isEmpty - } - - public var keys: [CacheKey] { - return Array(storage.keys) - } - - @discardableResult public mutating func merge(records: RecordSet) -> Set { - var changedKeys: Set = Set() - - for (_, record) in records.storage { - changedKeys.formUnion(merge(record: record)) - } - - return changedKeys - } - - @discardableResult public mutating func merge(record: Record) -> Set { - if var oldRecord = storage.removeValue(forKey: record.key) { - var changedKeys: Set = Set() - - for (key, value) in record.fields { - if let oldValue = oldRecord.fields[key], equals(oldValue, value) { - continue - } - oldRecord[key] = value - changedKeys.insert([record.key, key].joined(separator: ".")) - } - storage[record.key] = oldRecord - return changedKeys - } else { - storage[record.key] = record - return Set(record.fields.keys.map { [record.key, $0].joined(separator: ".") }) - } - } -} - -extension RecordSet: ExpressibleByDictionaryLiteral { - public init(dictionaryLiteral elements: (CacheKey, Record.Fields)...) { - self.init(records: elements.map { Record(key: $0.0, $0.1) }) - } -} - -extension RecordSet: CustomStringConvertible { - public var description: String { - return String(describing: Array(storage.values)) - } -} - -extension RecordSet: CustomPlaygroundDisplayConvertible { - public var playgroundDescription: Any { - return description - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/Result.swift b/Example/Pods/Apollo/Sources/Apollo/Result.swift deleted file mode 100644 index 5fe54c4..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/Result.swift +++ /dev/null @@ -1,44 +0,0 @@ -public enum Result { - case success(Value) - case failure(Error) -} - -extension Result: CustomStringConvertible { - public var description: String { - switch self { - case .success(let value): - return "Success(\(value))" - case .failure(let error): - return "Error(\(error))" - } - } -} - -extension Result { - var value: Value? { - switch self { - case .success(let value): - return value - case .failure(_): - return nil - } - } - - var error: Error? { - switch self { - case .success(_): - return nil - case .failure(let error): - return error - } - } - - func valueOrError() throws -> Value { - switch self { - case .success(let value): - return value - case .failure(let error): - throw error - } - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/ResultOrPromise.swift b/Example/Pods/Apollo/Sources/Apollo/ResultOrPromise.swift deleted file mode 100644 index 2783958..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/ResultOrPromise.swift +++ /dev/null @@ -1,152 +0,0 @@ -import Dispatch - -public func whenAll(_ resultsOrPromises: [ResultOrPromise], notifyOn queue: DispatchQueue = .global()) -> ResultOrPromise<[Value]> { - onlyResults: do { - var results: [Result] = [] - for resultOrPromise in resultsOrPromises { - guard case .result(let result) = resultOrPromise else { - break onlyResults - } - results.append(result) - } - do { - let values = try results.map { try $0.valueOrError() } - return .result(.success(values)) - } catch { - return .result(.failure(error)) - } - } - - return .promise(Promise { (fulfill, reject) in - let group = DispatchGroup() - - for resultOrPromise in resultsOrPromises { - group.enter() - - resultOrPromise.andThen { value in - group.leave() - }.catch { error in - reject(error) - } - } - - group.notify(queue: queue) { - fulfill(resultsOrPromises.map { $0.result!.value! }) - } - }) -} - -public enum ResultOrPromise { - case result(Result) - case promise(Promise) - - public init(_ body: () throws -> Value) { - do { - let value = try body() - self = .result(.success(value)) - } catch { - self = .result(.failure(error)) - } - } - - public var result: Result? { - switch self { - case .result(let result): - return result - case .promise(let promise): - return promise.result - } - } - - public func await() throws -> Value { - switch self { - case .result(let result): - return try result.valueOrError() - case .promise(let promise): - return try promise.await() - } - } - - func asPromise() -> Promise { - switch self { - case .result(let result): - return Promise(resolved: result) - case .promise(let promise): - return promise - } - } - - @discardableResult public func andThen(_ whenFulfilled: @escaping (Value) throws -> Void) -> ResultOrPromise { - switch self { - case .result(.success(let value)): - do { - try whenFulfilled(value) - return .result(.success(value)) - } catch { - return .result(.failure(error)) - } - case .result(.failure(let error)): - return .result(.failure(error)) - case .promise(let promise): - return .promise(promise.andThen(whenFulfilled)) - } - } - - @discardableResult public func `catch`(_ whenRejected: @escaping (Error) throws -> Void) -> ResultOrPromise { - switch self { - case .result(.success(let value)): - return .result(.success(value)) - case .result(.failure(let error)): - do { - try whenRejected(error) - return .result(.failure(error)) - } catch { - return .result(.failure(error)) - } - case .promise(let promise): - return .promise(promise.`catch`(whenRejected)) - } - } - - public func map(_ transform: @escaping (Value) throws -> T) -> ResultOrPromise { - switch self { - case .result(.success(let value)): - do { - return .result(.success(try transform(value))) - } catch { - return .result(.failure(error)) - } - case .result(.failure(let error)): - return .result(.failure(error)) - case .promise(let promise): - return .promise(promise.map { value in - return try transform(value) - }) - } - } - - public func flatMap(_ transform: @escaping (Value) throws -> ResultOrPromise) -> ResultOrPromise { - switch self { - case .result(.success(let value)): - do { - return try transform(value) - } catch { - return .result(.failure(error)) - } - case .result(.failure(let error)): - return .result(.failure(error)) - case .promise(let promise): - return .promise(promise.flatMap { value in - return try transform(value).asPromise() - }) - } - } - - public func on(queue: DispatchQueue) -> ResultOrPromise { - if case .promise(let promise) = self { - return .promise(promise.on(queue: queue)) - } else { - return self - } - } -} diff --git a/Example/Pods/Apollo/Sources/Apollo/Utilities.swift b/Example/Pods/Apollo/Sources/Apollo/Utilities.swift deleted file mode 100644 index 4778c3e..0000000 --- a/Example/Pods/Apollo/Sources/Apollo/Utilities.swift +++ /dev/null @@ -1,23 +0,0 @@ -import Foundation - -extension HTTPURLResponse { - var isSuccessful: Bool { - return (200..<300).contains(statusCode) - } - - var statusCodeDescription: String { - return HTTPURLResponse.localizedString(forStatusCode: statusCode) - } - - var textEncoding: String.Encoding? { - guard let encodingName = textEncodingName else { return nil } - - return String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding(encodingName as CFString))) - } -} - -public protocol Matchable { - associatedtype Base - static func ~=(pattern: Self, value: Base) -> Bool -} - diff --git a/Example/Pods/Apollo/scripts/check-and-run-apollo-cli.sh b/Example/Pods/Apollo/scripts/check-and-run-apollo-cli.sh deleted file mode 100755 index ab091d5..0000000 --- a/Example/Pods/Apollo/scripts/check-and-run-apollo-cli.sh +++ /dev/null @@ -1,90 +0,0 @@ -# Only major and minor version should be specified here -REQUIRED_APOLLO_CLI_VERSION=1.9 -# Specify fully qualified version here. Ideally this should be a LTS version. -REQUIRED_NODE_VERSION=8.15.0 - -# Using npx to execute 'apollo' looks for a local install in node_modules before checking $PATH (for a global install) -APOLLO_CLI="npx --no-install apollo" - -# Part of this code has been adapted from -# https://github.com/facebook/react-native/blob/master/scripts/react-native-xcode.sh - -# This script is supposed to be invoked as part of the Xcode build process -# and relies on environment variables set by Xcode - -if [[ -z "$CONFIGURATION" ]]; then - echo "$0 must be invoked as part of an Xcode script phase" - exit 1 -fi - -use_correct_node_via_nvm() { - nvm version $REQUIRED_NODE_VERSION > /dev/null - if [[ $? -eq 0 ]]; then - # The version of node that we want is installed. - nvm use $REQUIRED_NODE_VERSION - else - nvm install $REQUIRED_NODE_VERSION - fi -} - -use_correct_node_via_nodenv() { - nodenv install -s $REQUIRED_NODE_VERSION - nodenv shell $REQUIRED_NODE_VERSION -} - -if [[ -s "$HOME/.nvm/nvm.sh" ]]; then - . "$HOME/.nvm/nvm.sh" - use_correct_node_via_nvm -elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then - . "$(brew --prefix nvm)/nvm.sh" - use_correct_node_via_nvm -fi - -# Set up the nodenv node version manager if present -if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then - eval "$("$HOME/.nodenv/bin/nodenv" init -)" - use_correct_node_via_nodenv -fi - -parse_version() { - if [[ $1 =~ ([0-9\.]+) ]]; then - echo ${BASH_REMATCH[1]} - fi -} - -get_installed_cli_version() { - version=$($APOLLO_CLI -v) - if [[ $? -eq 0 ]]; then - echo "$version" - fi -} - -# We consider versions to be compatible if the major and minor versions match -are_versions_compatible() { - [[ "$(parse_version $1 | cut -d. -f1-2)" == $2 ]] -} - -install_apollo_cli() { - echo "warning: Installing apollo@$REQUIRED_APOLLO_CLI_VERSION in your project directory to avoid version conflicts..." - # Exit immediately if the command fails - set -e - npm install --prefix "$PROJECT_DIR" --no-package-lock apollo@$REQUIRED_APOLLO_CLI_VERSION - set +e -} - -# Check the installed version of the Apollo CLI, if available -INSTALLED_APOLLO_CLI_VERSION="$(get_installed_cli_version)" - -if [[ -z "$INSTALLED_APOLLO_CLI_VERSION" ]]; then - echo "warning: Apollo iOS requires version $REQUIRED_APOLLO_CLI_VERSION.x of the Apollo CLI to be installed \ -either globally or in a local node_modules directory." - install_apollo_cli -elif ! are_versions_compatible "$INSTALLED_APOLLO_CLI_VERSION" $REQUIRED_APOLLO_CLI_VERSION; then - echo "warning: The version of Apollo.framework in your project requires Apollo CLI $REQUIRED_APOLLO_CLI_VERSION.x, \ -but $INSTALLED_APOLLO_CLI_VERSION seems to be installed." - install_apollo_cli -fi - -# Print commands before executing them (useful for troubleshooting) -set -x -$APOLLO_CLI "$@" diff --git a/Example/Pods/Apollo/scripts/check-and-run-apollo-codegen.sh b/Example/Pods/Apollo/scripts/check-and-run-apollo-codegen.sh deleted file mode 100755 index ca91282..0000000 --- a/Example/Pods/Apollo/scripts/check-and-run-apollo-codegen.sh +++ /dev/null @@ -1,2 +0,0 @@ -echo "error: Please update your code generation build phase script to use the new Apollo CLI, see https://www.apollographql.com/docs/ios/installation.html#adding-build-step" -exit 1 diff --git a/Example/Pods/Local Podspecs/ApolloAlamofire.podspec.json b/Example/Pods/Local Podspecs/ApolloAlamofire.podspec.json deleted file mode 100644 index 7ab0609..0000000 --- a/Example/Pods/Local Podspecs/ApolloAlamofire.podspec.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "ApolloAlamofire", - "version": "0.5.0", - "summary": "Alamofire transport for Apollo iOS GraphQL library", - "swift_versions": "4.2", - "description": "This package bundles a `NetworkTransport` implementation that wraps Alamofire\nand solves known limitations of Apollo iOS library.", - "homepage": "https://github.com/graphql-community/ApolloAlamofire", - "license": { - "type": "MIT", - "file": "LICENSE" - }, - "authors": { - "Max Desiatov": "max@desiatov.com" - }, - "source": { - "git": "https://github.com/graphql-community/ApolloAlamofire.git", - "tag": "0.5.0" - }, - "platforms": { - "ios": "9.0" - }, - "source_files": "ApolloAlamofire/Classes/**/*", - "dependencies": { - "Alamofire": [ - "~> 4.8.2" - ], - "Apollo": [ - "~> 0.10.1" - ] - }, - "swift_version": "4.2" -} diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock deleted file mode 100644 index 7c3956d..0000000 --- a/Example/Pods/Manifest.lock +++ /dev/null @@ -1,29 +0,0 @@ -PODS: - - Alamofire (4.8.2) - - Apollo (0.10.1): - - Apollo/Core (= 0.10.1) - - Apollo/Core (0.10.1) - - ApolloAlamofire (0.5.0): - - Alamofire (~> 4.8.2) - - Apollo (~> 0.10.1) - -DEPENDENCIES: - - ApolloAlamofire (from `../`) - -SPEC REPOS: - https://github.com/cocoapods/specs.git: - - Alamofire - - Apollo - -EXTERNAL SOURCES: - ApolloAlamofire: - :path: "../" - -SPEC CHECKSUMS: - Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3 - Apollo: 4d690a9b2e48e8820182df4b988d7a253e1ee589 - ApolloAlamofire: cb21686240a36b3500f3dbd318c88cfd14d15d77 - -PODFILE CHECKSUM: 3d8d02ef1af8e9f3ad5f5d2ba9652a1dafc83875 - -COCOAPODS: 1.7.3 diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj deleted file mode 100644 index 1b81496..0000000 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1205 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 05006B498A58D7F8A26BDAC0EA3FA64B /* ResultOrPromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FA64CF3E9BEC5CE70576F1D51C0F240 /* ResultOrPromise.swift */; }; - 0C5E11DE24DAA737704B355F5F2F3426 /* ParameterEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80CE9B29D97D8EBADAA10F5DE054569 /* ParameterEncoding.swift */; }; - 0E57A0FCD033DCF2591EE89A5E9A95E0 /* check-and-run-apollo-codegen.sh in Resources */ = {isa = PBXBuildFile; fileRef = 63EBE061387B1B17E27A9EB833EA4A00 /* check-and-run-apollo-codegen.sh */; }; - 0F52D2EEF4D3CB5B8BCC8D33BD699BB6 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45F1425C95A31ECA0506C19706F1A120 /* Utilities.swift */; }; - 120ABB8E306A42CB349EAE5C0C37ECCA /* RecordSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABBF9B37118823F0510D11326C5AA610 /* RecordSet.swift */; }; - 1246082886637CBA9328078C6159565B /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 019FFC0FE7AD321FA46DBAD78A9AF26D /* Alamofire.framework */; }; - 132E0F619E4338E5D1B27E4C72076B3F /* Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E39937DD9B809B6477A6A0C1B43AA3D /* Notifications.swift */; }; - 1945CD5D63A1C164AEAAA9A33E85571E /* Alamofire-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 99B1842D407D172A59BEA90FB51E9785 /* Alamofire-dummy.m */; }; - 1986B50C74F1697EA43F68335C93CEB3 /* MultipartFormData.swift in Sources */ = {isa = PBXBuildFile; fileRef = E63D570810E41571112618A7D8E510E2 /* MultipartFormData.swift */; }; - 2139F3CD00F2798F57FA6B63A27C11F8 /* NormalizedCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAFE1451D6701426FA50392E98631C4 /* NormalizedCache.swift */; }; - 261C5C30E9F8CA98AD23B3F4BE7C09D8 /* GraphQLQueryWatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82F4A1889DB686893123F1659A5C4DF6 /* GraphQLQueryWatcher.swift */; }; - 2C61B040BA6A9A7AE66C4D9BA26D5520 /* SessionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82B37A1564C42366A4BD64D0C319DF38 /* SessionDelegate.swift */; }; - 30B7EC5CCBAFC80A2D721A50BAF1C938 /* GraphQLError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C66827980DB08CD05A51B2B276A1A4F /* GraphQLError.swift */; }; - 3571F958A3907B3A806E62D50C2550D4 /* NetworkReachabilityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF6DD5ADEA6858C75F6E2169DCFF39D7 /* NetworkReachabilityManager.swift */; }; - 3692130EDEAB70F20A7EA43CD4F92BA4 /* Pods-ExampleTests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 990D5081B4A254BD345E64157052CD10 /* Pods-ExampleTests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 40EDBFE770257924149D1EB6C29C9B64 /* GraphQLDependencyTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB8EFA6893FDDE8A2256E2653C59528E /* GraphQLDependencyTracker.swift */; }; - 53791F5E5F07400F92CFDFC89A432305 /* Validation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E322523047C6E72CF9A70F07FB8C02F /* Validation.swift */; }; - 56FEA6F302B52260174CED6F85C93C19 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 946ADB5F075B7526EEEC3FCF4A88EE1E /* Foundation.framework */; }; - 597D74F292EF51A7B0D14CE8D77287E7 /* GraphQLSelectionSetMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53819DD0A6127BE8E1DA0F82D1CA6A78 /* GraphQLSelectionSetMapper.swift */; }; - 64744C911253C3E01461FAD7C935C8D7 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = E645EDB23EF1D2D7863E43B44D341814 /* Result.swift */; }; - 751A13CA1F2D6B41555E7C4D8586FACD /* JSONStandardTypeConversions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D18B9813BD23DB01C641985D7008C49 /* JSONStandardTypeConversions.swift */; }; - 7664FD4F59A0C00866CBAE60B0A3AD64 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 946ADB5F075B7526EEEC3FCF4A88EE1E /* Foundation.framework */; }; - 7B7401ECF183CDACF3470F282AB6118D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 946ADB5F075B7526EEEC3FCF4A88EE1E /* Foundation.framework */; }; - 7E89BB52104E5C9A071A9CC48B65AEF2 /* GraphQLResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5C1D0D1B7A63018942E45CEC99BDA4 /* GraphQLResponse.swift */; }; - 7F83B0476EF971C2DDD4BF1E12E6CD30 /* ApolloAlamofire-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 276066028F9C2EA61E7240C347CDDFAB /* ApolloAlamofire-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 83956E20859CDBBE7BC38ABADE0170FB /* AFError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65ACCDD179F236C8B27253E549096B47 /* AFError.swift */; }; - 8787F5B632CF9A0F302CED90AFB694F1 /* Record.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86FCD7BCCCF1A904FF08A14EA56CB9BD /* Record.swift */; }; - 87E7EB3791F61374EFD8E63E4545FDB9 /* InMemoryNormalizedCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086FB1CEB87A0FC07B741C14ECA2D1C6 /* InMemoryNormalizedCache.swift */; }; - 931BBB8230A25161D5C37528A8F9FECF /* SessionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA11A5B79E49CFD34DAC103CBD5A6D3 /* SessionManager.swift */; }; - 933FDA5970AA525D6CB92BFEBA2BAB4A /* Timeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43B0679401679624E2025E71DAADFAB9 /* Timeline.swift */; }; - 95680EC9226653178A302E6FEB244454 /* HTTPNetworkTransport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DC73A47EF555AADFAFAE6C8B958C85C /* HTTPNetworkTransport.swift */; }; - 95B16F88F11EA91821A745A488501F01 /* GraphQLResultNormalizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83FDE96FEF78A708D804D07AE6622631 /* GraphQLResultNormalizer.swift */; }; - 9674E10F14B21179B45026979006FE19 /* Collections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14BC4A577A94D60D79BCE5409BDEACA8 /* Collections.swift */; }; - 973F72124FAB66C4120931656A1D5EC5 /* GraphQLExecutor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86D47893B5E1528506E1B31DEFBC5052 /* GraphQLExecutor.swift */; }; - 98A929C8E9012AB167672714FFD2113C /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1A5C039116E2FF88EAF1679BEABEB07 /* Request.swift */; }; - 9AA759B4D4311BCA2E01256C322C48C2 /* GraphQLSelectionSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 999727BEFA21407EB256746E6C8B8521 /* GraphQLSelectionSet.swift */; }; - A95D757DE0D3A243A6B261524FE3584E /* AsynchronousOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35F97248635EC084E1C65BD036DC5327 /* AsynchronousOperation.swift */; }; - AAD3E591C7836677D61E48ED1B067151 /* Locking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C62ACC1A295954A54A6980DBA248819 /* Locking.swift */; }; - AFC64B1097F7355FF423D6A73E9C7210 /* TaskDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E4433007E29867E87FD4E9B6C9978C2 /* TaskDelegate.swift */; }; - B02D7FF97A812594E57E36998242D83F /* GraphQLOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C46D483559C81BE38714678517843 /* GraphQLOperation.swift */; }; - B0E3C5B5FFE47D8E0DF2E5F1E01D0D44 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C7250F5737BDAD689440F33EE1E4461 /* Result.swift */; }; - B35F5B7C07D5FBC9D33D561BD7DC8B01 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31E36D6EAF58E7D9D315D1F5ADFE6E13 /* JSON.swift */; }; - B68D428F1F33ABA2BE53046C4201A842 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 946ADB5F075B7526EEEC3FCF4A88EE1E /* Foundation.framework */; }; - B751C06583B9F408F3C76410759CA6EA /* GraphQLResponseGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF148F0BAEFC9AD5121FC73FA3F9DE3D /* GraphQLResponseGenerator.swift */; }; - B773D9B5E1E6310D686366804877B4A0 /* ApolloAlamofire-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 52C854D34E83A2620A2423A3AC5D971E /* ApolloAlamofire-dummy.m */; }; - B95015339DB91B13E5ADDD9A4DF9ACC9 /* Apollo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C47B3F9D3A9E7A198186A2DB6CFFB6EB /* Apollo.framework */; }; - BEE6B677416CA71C981D1D3F60B18C96 /* Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538085E8A2E7470E7F63DB06576E8D9B /* Alamofire.swift */; }; - C774A69F0F79A828351A109548619CFE /* GraphQLInputValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568C31E9543B4DACBD627708F3129C3E /* GraphQLInputValue.swift */; }; - C7BA21EB285B98FE70C39FC6BE8923B7 /* ApolloClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = F939C50B4AC40E8411E4FB30D313F2BF /* ApolloClient.swift */; }; - CB2C2AC79E10889EC840CD6C3D24F96F /* Apollo-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = E5970ECF111CB0E4D500D988B7F7F9EB /* Apollo-dummy.m */; }; - CB830C3777A5C5452B0A1D208BF8E99C /* AlamofireTransport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324EE673E65C40B8427D1CD93D243156 /* AlamofireTransport.swift */; }; - D05B95B0818C14DBB6EDE674B636A995 /* Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67F764F71E78C1BA427DE211C63ED311 /* Promise.swift */; }; - D07C40C35E6D7667770BE02E7058B932 /* Apollo-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = AC1963D01CFF9BC54FE38C5936E792B1 /* Apollo-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D3D8C379C6E4FB487E5ABD6800AD7B7E /* DispatchQueue+Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = C174BC4EC5B32E3F2E2234AD57ABE4AE /* DispatchQueue+Alamofire.swift */; }; - D65C254F5ABF2CB5ECEE50FE8F8E1A80 /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49FF3D9C213E8D7C62522E2DF9D796C4 /* Response.swift */; }; - D706082B53ACEEDFC2EBB068D2F5C14C /* Pods-ExampleTests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B88FE341015B15948D4B7230705AF8D /* Pods-ExampleTests-dummy.m */; }; - D96A02B8657B7BCB64C3211E44EF4825 /* JSONSerializationFormat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F864FE8C2DA6E220DE4408720D6461D /* JSONSerializationFormat.swift */; }; - D9A6ED89859B7845939B3C864D7EA759 /* check-and-run-apollo-cli.sh in Resources */ = {isa = PBXBuildFile; fileRef = 140CBCC4E034880D0B183873B857B1BE /* check-and-run-apollo-cli.sh */; }; - E3747EC31FCCA97D75A81FC700CF7E24 /* ResponseSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52D49706D2A47F47B8A781B9097C7A68 /* ResponseSerialization.swift */; }; - E54965381A172A8BA53D4049B7FEDD41 /* ApolloStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC7AF80B33042F3F201BFB821929FE1 /* ApolloStore.swift */; }; - E80A257C39F55BEDB0AF6F4AF035674E /* NetworkTransport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1E5386755D307DB378F1D72CC818DB /* NetworkTransport.swift */; }; - EECD898523E8110738B378422D93B69F /* GraphQLResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = F736BF510C99F67CF4A068BE639B0501 /* GraphQLResult.swift */; }; - F13F2AA7F2E6D95A181CAB99B900D531 /* ServerTrustPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A364B6A7C1A2D2B0D0F392C46FEF0D8 /* ServerTrustPolicy.swift */; }; - F7B74645E07C39771156A1FA413B98D4 /* Alamofire-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F22D6ABDAAF1D9362919C962A4C3D81 /* Alamofire-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - FC5B4DE6F6AD773481EABECF2AA4C6AC /* GraphQLResultAccumulator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E994339CCF17BFD138D085503DB854F3 /* GraphQLResultAccumulator.swift */; }; - FFF1EA5D590D8EF4780539985010797F /* DataLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62C2E10EA38E7346A23CA744CDBB5C5D /* DataLoader.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 3A563B588E67BA0299053645B77E9A0D /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; - proxyType = 1; - remoteGlobalIDString = EAAA1AD3A8A1B59AB91319EE40752C6D; - remoteInfo = Alamofire; - }; - ADD626D417891997410FCE696FD9B799 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 6F3BE004A950C21FCFC67D7CF2961F40; - remoteInfo = ApolloAlamofire; - }; - DF8663B36CBECCF976ABC5C2E43496AE /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 30EE3CABB612307A688C40B61BFA74CC; - remoteInfo = Apollo; - }; - EBE9910CE30DA1BE956ADD2C83925D07 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 30EE3CABB612307A688C40B61BFA74CC; - remoteInfo = Apollo; - }; - FB56DDB9912324F872499E52876EA737 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; - proxyType = 1; - remoteGlobalIDString = EAAA1AD3A8A1B59AB91319EE40752C6D; - remoteInfo = Alamofire; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 019FFC0FE7AD321FA46DBAD78A9AF26D /* Alamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Alamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 02E0D03D161FCA3F51FB13C2023F2CE3 /* Pods-ExampleTests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-ExampleTests.modulemap"; sourceTree = ""; }; - 086FB1CEB87A0FC07B741C14ECA2D1C6 /* InMemoryNormalizedCache.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = InMemoryNormalizedCache.swift; path = Sources/Apollo/InMemoryNormalizedCache.swift; sourceTree = ""; }; - 09CB6C0E5EADB633B3035B7ABA4A2A3B /* Alamofire-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Alamofire-Info.plist"; sourceTree = ""; }; - 0BC7AF80B33042F3F201BFB821929FE1 /* ApolloStore.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ApolloStore.swift; path = Sources/Apollo/ApolloStore.swift; sourceTree = ""; }; - 0C7250F5737BDAD689440F33EE1E4461 /* Result.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Result.swift; path = Sources/Apollo/Result.swift; sourceTree = ""; }; - 140CBCC4E034880D0B183873B857B1BE /* check-and-run-apollo-cli.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; name = "check-and-run-apollo-cli.sh"; path = "scripts/check-and-run-apollo-cli.sh"; sourceTree = ""; }; - 14BC4A577A94D60D79BCE5409BDEACA8 /* Collections.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Collections.swift; path = Sources/Apollo/Collections.swift; sourceTree = ""; }; - 1744369300E148EDB028501150D6DE00 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; }; - 1C1E5386755D307DB378F1D72CC818DB /* NetworkTransport.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NetworkTransport.swift; path = Sources/Apollo/NetworkTransport.swift; sourceTree = ""; }; - 1C9611A0D410E095262A2095D8CB0A93 /* Pods-ExampleTests-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-ExampleTests-Info.plist"; sourceTree = ""; }; - 1CAFE1451D6701426FA50392E98631C4 /* NormalizedCache.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NormalizedCache.swift; path = Sources/Apollo/NormalizedCache.swift; sourceTree = ""; }; - 1E39937DD9B809B6477A6A0C1B43AA3D /* Notifications.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Notifications.swift; path = Source/Notifications.swift; sourceTree = ""; }; - 276066028F9C2EA61E7240C347CDDFAB /* ApolloAlamofire-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ApolloAlamofire-umbrella.h"; sourceTree = ""; }; - 287CAB3D9B2D3D365385E985CBCC616D /* Pods-ExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ExampleTests.release.xcconfig"; sourceTree = ""; }; - 2CA11A5B79E49CFD34DAC103CBD5A6D3 /* SessionManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SessionManager.swift; path = Source/SessionManager.swift; sourceTree = ""; }; - 2E322523047C6E72CF9A70F07FB8C02F /* Validation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Validation.swift; path = Source/Validation.swift; sourceTree = ""; }; - 2E4433007E29867E87FD4E9B6C9978C2 /* TaskDelegate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TaskDelegate.swift; path = Source/TaskDelegate.swift; sourceTree = ""; }; - 31E36D6EAF58E7D9D315D1F5ADFE6E13 /* JSON.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JSON.swift; path = Sources/Apollo/JSON.swift; sourceTree = ""; }; - 324EE673E65C40B8427D1CD93D243156 /* AlamofireTransport.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AlamofireTransport.swift; path = ApolloAlamofire/Classes/AlamofireTransport.swift; sourceTree = ""; }; - 35F97248635EC084E1C65BD036DC5327 /* AsynchronousOperation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AsynchronousOperation.swift; path = Sources/Apollo/AsynchronousOperation.swift; sourceTree = ""; }; - 380A18E2C84AE29334F12DBE7811E2CB /* Pods-ExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ExampleTests.debug.xcconfig"; sourceTree = ""; }; - 39C164E5D3807CA34B7ACD1B6C2302A9 /* ApolloAlamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = ApolloAlamofire.framework; path = ApolloAlamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 3A364B6A7C1A2D2B0D0F392C46FEF0D8 /* ServerTrustPolicy.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ServerTrustPolicy.swift; path = Source/ServerTrustPolicy.swift; sourceTree = ""; }; - 3DC73A47EF555AADFAFAE6C8B958C85C /* HTTPNetworkTransport.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = HTTPNetworkTransport.swift; path = Sources/Apollo/HTTPNetworkTransport.swift; sourceTree = ""; }; - 3FA64CF3E9BEC5CE70576F1D51C0F240 /* ResultOrPromise.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ResultOrPromise.swift; path = Sources/Apollo/ResultOrPromise.swift; sourceTree = ""; }; - 43B0679401679624E2025E71DAADFAB9 /* Timeline.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Timeline.swift; path = Source/Timeline.swift; sourceTree = ""; }; - 451453CE82BFA2CB07FC5EBF16AD38EC /* ApolloAlamofire.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = ApolloAlamofire.xcconfig; sourceTree = ""; }; - 45F1425C95A31ECA0506C19706F1A120 /* Utilities.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Utilities.swift; path = Sources/Apollo/Utilities.swift; sourceTree = ""; }; - 490B737716AEB036034053E5F2992EB5 /* Alamofire-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Alamofire-prefix.pch"; sourceTree = ""; }; - 49FF3D9C213E8D7C62522E2DF9D796C4 /* Response.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Response.swift; path = Source/Response.swift; sourceTree = ""; }; - 52C854D34E83A2620A2423A3AC5D971E /* ApolloAlamofire-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "ApolloAlamofire-dummy.m"; sourceTree = ""; }; - 52D49706D2A47F47B8A781B9097C7A68 /* ResponseSerialization.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ResponseSerialization.swift; path = Source/ResponseSerialization.swift; sourceTree = ""; }; - 538085E8A2E7470E7F63DB06576E8D9B /* Alamofire.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Alamofire.swift; path = Source/Alamofire.swift; sourceTree = ""; }; - 53819DD0A6127BE8E1DA0F82D1CA6A78 /* GraphQLSelectionSetMapper.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLSelectionSetMapper.swift; path = Sources/Apollo/GraphQLSelectionSetMapper.swift; sourceTree = ""; }; - 568C31E9543B4DACBD627708F3129C3E /* GraphQLInputValue.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLInputValue.swift; path = Sources/Apollo/GraphQLInputValue.swift; sourceTree = ""; }; - 5B88FE341015B15948D4B7230705AF8D /* Pods-ExampleTests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-ExampleTests-dummy.m"; sourceTree = ""; }; - 5D797E9A5C5782CE845840781FA1CC81 /* Alamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Alamofire.framework; path = Alamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 5F22D6ABDAAF1D9362919C962A4C3D81 /* Alamofire-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Alamofire-umbrella.h"; sourceTree = ""; }; - 62C2E10EA38E7346A23CA744CDBB5C5D /* DataLoader.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DataLoader.swift; path = Sources/Apollo/DataLoader.swift; sourceTree = ""; }; - 630CABE8F692FCDBFD1B122A2D0CE388 /* Pods_ExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_ExampleTests.framework; path = "Pods-ExampleTests.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; - 63EBE061387B1B17E27A9EB833EA4A00 /* check-and-run-apollo-codegen.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; name = "check-and-run-apollo-codegen.sh"; path = "scripts/check-and-run-apollo-codegen.sh"; sourceTree = ""; }; - 65ACCDD179F236C8B27253E549096B47 /* AFError.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AFError.swift; path = Source/AFError.swift; sourceTree = ""; }; - 67F764F71E78C1BA427DE211C63ED311 /* Promise.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Promise.swift; path = Sources/Apollo/Promise.swift; sourceTree = ""; }; - 6D4C46D483559C81BE38714678517843 /* GraphQLOperation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLOperation.swift; path = Sources/Apollo/GraphQLOperation.swift; sourceTree = ""; }; - 78EB9BF360D71EE7D77F6238AEBDA56F /* ApolloAlamofire-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "ApolloAlamofire-Info.plist"; sourceTree = ""; }; - 7C62ACC1A295954A54A6980DBA248819 /* Locking.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Locking.swift; path = Sources/Apollo/Locking.swift; sourceTree = ""; }; - 8231E933F2036997C124421FF6B3ADBC /* Apollo-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Apollo-Info.plist"; sourceTree = ""; }; - 82B37A1564C42366A4BD64D0C319DF38 /* SessionDelegate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SessionDelegate.swift; path = Source/SessionDelegate.swift; sourceTree = ""; }; - 82F4A1889DB686893123F1659A5C4DF6 /* GraphQLQueryWatcher.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLQueryWatcher.swift; path = Sources/Apollo/GraphQLQueryWatcher.swift; sourceTree = ""; }; - 83FDE96FEF78A708D804D07AE6622631 /* GraphQLResultNormalizer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLResultNormalizer.swift; path = Sources/Apollo/GraphQLResultNormalizer.swift; sourceTree = ""; }; - 86D47893B5E1528506E1B31DEFBC5052 /* GraphQLExecutor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLExecutor.swift; path = Sources/Apollo/GraphQLExecutor.swift; sourceTree = ""; }; - 86FCD7BCCCF1A904FF08A14EA56CB9BD /* Record.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Record.swift; path = Sources/Apollo/Record.swift; sourceTree = ""; }; - 8D18B9813BD23DB01C641985D7008C49 /* JSONStandardTypeConversions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JSONStandardTypeConversions.swift; path = Sources/Apollo/JSONStandardTypeConversions.swift; sourceTree = ""; }; - 8F1FA46A3C7AA9081BA3650A49BDE9FE /* Apollo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Apollo.framework; path = Apollo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 946ADB5F075B7526EEEC3FCF4A88EE1E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - 96EF831100D814BC04B00CDCBD42705D /* Pods-ExampleTests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-ExampleTests-acknowledgements.markdown"; sourceTree = ""; }; - 990D5081B4A254BD345E64157052CD10 /* Pods-ExampleTests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-ExampleTests-umbrella.h"; sourceTree = ""; }; - 999727BEFA21407EB256746E6C8B8521 /* GraphQLSelectionSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLSelectionSet.swift; path = Sources/Apollo/GraphQLSelectionSet.swift; sourceTree = ""; }; - 99B1842D407D172A59BEA90FB51E9785 /* Alamofire-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Alamofire-dummy.m"; sourceTree = ""; }; - 9C66827980DB08CD05A51B2B276A1A4F /* GraphQLError.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLError.swift; path = Sources/Apollo/GraphQLError.swift; sourceTree = ""; }; - 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - 9F864FE8C2DA6E220DE4408720D6461D /* JSONSerializationFormat.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JSONSerializationFormat.swift; path = Sources/Apollo/JSONSerializationFormat.swift; sourceTree = ""; }; - A16F93BA523003A1EF54C1EBEBE72B7A /* Alamofire.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = Alamofire.modulemap; sourceTree = ""; }; - AB55F31B9A6E601AA392FFDA8DFD0FDE /* Apollo-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Apollo-prefix.pch"; sourceTree = ""; }; - ABBF9B37118823F0510D11326C5AA610 /* RecordSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RecordSet.swift; path = Sources/Apollo/RecordSet.swift; sourceTree = ""; }; - AC1963D01CFF9BC54FE38C5936E792B1 /* Apollo-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Apollo-umbrella.h"; sourceTree = ""; }; - AFA574C23040442DABF1E27D12D75803 /* ApolloAlamofire.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = ApolloAlamofire.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - B1A5C039116E2FF88EAF1679BEABEB07 /* Request.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Request.swift; path = Source/Request.swift; sourceTree = ""; }; - BA36ED0795AD536A71990EDA6245AD98 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; }; - C174BC4EC5B32E3F2E2234AD57ABE4AE /* DispatchQueue+Alamofire.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "DispatchQueue+Alamofire.swift"; path = "Source/DispatchQueue+Alamofire.swift"; sourceTree = ""; }; - C1E7FD17E9DF9505367370BC48D4E400 /* Apollo.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Apollo.xcconfig; sourceTree = ""; }; - C3A74FD95BB4BB9B3DA964E65B926FCF /* ApolloAlamofire-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ApolloAlamofire-prefix.pch"; sourceTree = ""; }; - C47B3F9D3A9E7A198186A2DB6CFFB6EB /* Apollo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Apollo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D69587845CF50A79413B679C790F38B9 /* Alamofire.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Alamofire.xcconfig; sourceTree = ""; }; - D80CE9B29D97D8EBADAA10F5DE054569 /* ParameterEncoding.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ParameterEncoding.swift; path = Source/ParameterEncoding.swift; sourceTree = ""; }; - E05B5541C535417A1F792D29BF3EA582 /* Pods-ExampleTests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-ExampleTests-acknowledgements.plist"; sourceTree = ""; }; - E37F277E0E6D2BFA0ED3C0B83F6EE296 /* ApolloAlamofire.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = ApolloAlamofire.modulemap; sourceTree = ""; }; - E5970ECF111CB0E4D500D988B7F7F9EB /* Apollo-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Apollo-dummy.m"; sourceTree = ""; }; - E63D570810E41571112618A7D8E510E2 /* MultipartFormData.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = MultipartFormData.swift; path = Source/MultipartFormData.swift; sourceTree = ""; }; - E645EDB23EF1D2D7863E43B44D341814 /* Result.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Result.swift; path = Source/Result.swift; sourceTree = ""; }; - E994339CCF17BFD138D085503DB854F3 /* GraphQLResultAccumulator.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLResultAccumulator.swift; path = Sources/Apollo/GraphQLResultAccumulator.swift; sourceTree = ""; }; - EA5C1D0D1B7A63018942E45CEC99BDA4 /* GraphQLResponse.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLResponse.swift; path = Sources/Apollo/GraphQLResponse.swift; sourceTree = ""; }; - EB8EFA6893FDDE8A2256E2653C59528E /* GraphQLDependencyTracker.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLDependencyTracker.swift; path = Sources/Apollo/GraphQLDependencyTracker.swift; sourceTree = ""; }; - EF6DD5ADEA6858C75F6E2169DCFF39D7 /* NetworkReachabilityManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NetworkReachabilityManager.swift; path = Source/NetworkReachabilityManager.swift; sourceTree = ""; }; - F6DA91FEF4E336235005FCA0445FE5C2 /* Pods-ExampleTests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-ExampleTests-frameworks.sh"; sourceTree = ""; }; - F736BF510C99F67CF4A068BE639B0501 /* GraphQLResult.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLResult.swift; path = Sources/Apollo/GraphQLResult.swift; sourceTree = ""; }; - F939C50B4AC40E8411E4FB30D313F2BF /* ApolloClient.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ApolloClient.swift; path = Sources/Apollo/ApolloClient.swift; sourceTree = ""; }; - F9EE523594F8F59E818AE09013D97B26 /* Apollo.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = Apollo.modulemap; sourceTree = ""; }; - FF148F0BAEFC9AD5121FC73FA3F9DE3D /* GraphQLResponseGenerator.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GraphQLResponseGenerator.swift; path = Sources/Apollo/GraphQLResponseGenerator.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 090C1D63463ACF622287EFF9D5C9392D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 7664FD4F59A0C00866CBAE60B0A3AD64 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 3D353BAE84BB35AF2B0B3EC00286EE6E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 1246082886637CBA9328078C6159565B /* Alamofire.framework in Frameworks */, - B95015339DB91B13E5ADDD9A4DF9ACC9 /* Apollo.framework in Frameworks */, - 56FEA6F302B52260174CED6F85C93C19 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A2F77B8D67BB2A81DADE27AC4D16E9ED /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 7B7401ECF183CDACF3470F282AB6118D /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - D24D6B4373C2422E12E665B936305651 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - B68D428F1F33ABA2BE53046C4201A842 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 30050025CE53A7A2A2D0FA844F70EE96 /* ApolloAlamofire */ = { - isa = PBXGroup; - children = ( - 324EE673E65C40B8427D1CD93D243156 /* AlamofireTransport.swift */, - CE580CEBF79F44818C4895EA91A9ED95 /* Pod */, - 7840500F36B1BC537784A95D3DC61BCD /* Support Files */, - ); - name = ApolloAlamofire; - path = ../..; - sourceTree = ""; - }; - 3D61B0564D2EA856BC2EFDD7E82152F7 /* Products */ = { - isa = PBXGroup; - children = ( - 5D797E9A5C5782CE845840781FA1CC81 /* Alamofire.framework */, - 8F1FA46A3C7AA9081BA3650A49BDE9FE /* Apollo.framework */, - 39C164E5D3807CA34B7ACD1B6C2302A9 /* ApolloAlamofire.framework */, - 630CABE8F692FCDBFD1B122A2D0CE388 /* Pods_ExampleTests.framework */, - ); - name = Products; - sourceTree = ""; - }; - 3DB64DE0CD305423397F8407B66C98D7 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 019FFC0FE7AD321FA46DBAD78A9AF26D /* Alamofire.framework */, - C47B3F9D3A9E7A198186A2DB6CFFB6EB /* Apollo.framework */, - D937E2B52ACA61FCE3EBFC284B06A3BE /* iOS */, - ); - name = Frameworks; - sourceTree = ""; - }; - 5C1AC156F0E2BAD0150674A344343188 /* Support Files */ = { - isa = PBXGroup; - children = ( - A16F93BA523003A1EF54C1EBEBE72B7A /* Alamofire.modulemap */, - D69587845CF50A79413B679C790F38B9 /* Alamofire.xcconfig */, - 99B1842D407D172A59BEA90FB51E9785 /* Alamofire-dummy.m */, - 09CB6C0E5EADB633B3035B7ABA4A2A3B /* Alamofire-Info.plist */, - 490B737716AEB036034053E5F2992EB5 /* Alamofire-prefix.pch */, - 5F22D6ABDAAF1D9362919C962A4C3D81 /* Alamofire-umbrella.h */, - ); - name = "Support Files"; - path = "../Target Support Files/Alamofire"; - sourceTree = ""; - }; - 64022C6041A0CA3A72182F217FEF131A /* Core */ = { - isa = PBXGroup; - children = ( - F939C50B4AC40E8411E4FB30D313F2BF /* ApolloClient.swift */, - 0BC7AF80B33042F3F201BFB821929FE1 /* ApolloStore.swift */, - 35F97248635EC084E1C65BD036DC5327 /* AsynchronousOperation.swift */, - 14BC4A577A94D60D79BCE5409BDEACA8 /* Collections.swift */, - 62C2E10EA38E7346A23CA744CDBB5C5D /* DataLoader.swift */, - EB8EFA6893FDDE8A2256E2653C59528E /* GraphQLDependencyTracker.swift */, - 9C66827980DB08CD05A51B2B276A1A4F /* GraphQLError.swift */, - 86D47893B5E1528506E1B31DEFBC5052 /* GraphQLExecutor.swift */, - 568C31E9543B4DACBD627708F3129C3E /* GraphQLInputValue.swift */, - 6D4C46D483559C81BE38714678517843 /* GraphQLOperation.swift */, - 82F4A1889DB686893123F1659A5C4DF6 /* GraphQLQueryWatcher.swift */, - EA5C1D0D1B7A63018942E45CEC99BDA4 /* GraphQLResponse.swift */, - FF148F0BAEFC9AD5121FC73FA3F9DE3D /* GraphQLResponseGenerator.swift */, - F736BF510C99F67CF4A068BE639B0501 /* GraphQLResult.swift */, - E994339CCF17BFD138D085503DB854F3 /* GraphQLResultAccumulator.swift */, - 83FDE96FEF78A708D804D07AE6622631 /* GraphQLResultNormalizer.swift */, - 999727BEFA21407EB256746E6C8B8521 /* GraphQLSelectionSet.swift */, - 53819DD0A6127BE8E1DA0F82D1CA6A78 /* GraphQLSelectionSetMapper.swift */, - 3DC73A47EF555AADFAFAE6C8B958C85C /* HTTPNetworkTransport.swift */, - 086FB1CEB87A0FC07B741C14ECA2D1C6 /* InMemoryNormalizedCache.swift */, - 31E36D6EAF58E7D9D315D1F5ADFE6E13 /* JSON.swift */, - 9F864FE8C2DA6E220DE4408720D6461D /* JSONSerializationFormat.swift */, - 8D18B9813BD23DB01C641985D7008C49 /* JSONStandardTypeConversions.swift */, - 7C62ACC1A295954A54A6980DBA248819 /* Locking.swift */, - 1C1E5386755D307DB378F1D72CC818DB /* NetworkTransport.swift */, - 1CAFE1451D6701426FA50392E98631C4 /* NormalizedCache.swift */, - 67F764F71E78C1BA427DE211C63ED311 /* Promise.swift */, - 86FCD7BCCCF1A904FF08A14EA56CB9BD /* Record.swift */, - ABBF9B37118823F0510D11326C5AA610 /* RecordSet.swift */, - 0C7250F5737BDAD689440F33EE1E4461 /* Result.swift */, - 3FA64CF3E9BEC5CE70576F1D51C0F240 /* ResultOrPromise.swift */, - 45F1425C95A31ECA0506C19706F1A120 /* Utilities.swift */, - 6B0556AFB6B04AA486D2DC5F23B1B1BF /* Resources */, - ); - name = Core; - sourceTree = ""; - }; - 6B0556AFB6B04AA486D2DC5F23B1B1BF /* Resources */ = { - isa = PBXGroup; - children = ( - 140CBCC4E034880D0B183873B857B1BE /* check-and-run-apollo-cli.sh */, - 63EBE061387B1B17E27A9EB833EA4A00 /* check-and-run-apollo-codegen.sh */, - ); - name = Resources; - sourceTree = ""; - }; - 7840500F36B1BC537784A95D3DC61BCD /* Support Files */ = { - isa = PBXGroup; - children = ( - E37F277E0E6D2BFA0ED3C0B83F6EE296 /* ApolloAlamofire.modulemap */, - 451453CE82BFA2CB07FC5EBF16AD38EC /* ApolloAlamofire.xcconfig */, - 52C854D34E83A2620A2423A3AC5D971E /* ApolloAlamofire-dummy.m */, - 78EB9BF360D71EE7D77F6238AEBDA56F /* ApolloAlamofire-Info.plist */, - C3A74FD95BB4BB9B3DA964E65B926FCF /* ApolloAlamofire-prefix.pch */, - 276066028F9C2EA61E7240C347CDDFAB /* ApolloAlamofire-umbrella.h */, - ); - name = "Support Files"; - path = "Example/Pods/Target Support Files/ApolloAlamofire"; - sourceTree = ""; - }; - 7BF661162FBCAB6E4864272D6FF3D612 /* Alamofire */ = { - isa = PBXGroup; - children = ( - 65ACCDD179F236C8B27253E549096B47 /* AFError.swift */, - 538085E8A2E7470E7F63DB06576E8D9B /* Alamofire.swift */, - C174BC4EC5B32E3F2E2234AD57ABE4AE /* DispatchQueue+Alamofire.swift */, - E63D570810E41571112618A7D8E510E2 /* MultipartFormData.swift */, - EF6DD5ADEA6858C75F6E2169DCFF39D7 /* NetworkReachabilityManager.swift */, - 1E39937DD9B809B6477A6A0C1B43AA3D /* Notifications.swift */, - D80CE9B29D97D8EBADAA10F5DE054569 /* ParameterEncoding.swift */, - B1A5C039116E2FF88EAF1679BEABEB07 /* Request.swift */, - 49FF3D9C213E8D7C62522E2DF9D796C4 /* Response.swift */, - 52D49706D2A47F47B8A781B9097C7A68 /* ResponseSerialization.swift */, - E645EDB23EF1D2D7863E43B44D341814 /* Result.swift */, - 3A364B6A7C1A2D2B0D0F392C46FEF0D8 /* ServerTrustPolicy.swift */, - 82B37A1564C42366A4BD64D0C319DF38 /* SessionDelegate.swift */, - 2CA11A5B79E49CFD34DAC103CBD5A6D3 /* SessionManager.swift */, - 2E4433007E29867E87FD4E9B6C9978C2 /* TaskDelegate.swift */, - 43B0679401679624E2025E71DAADFAB9 /* Timeline.swift */, - 2E322523047C6E72CF9A70F07FB8C02F /* Validation.swift */, - 5C1AC156F0E2BAD0150674A344343188 /* Support Files */, - ); - name = Alamofire; - path = Alamofire; - sourceTree = ""; - }; - 917609DAAB736B589ABD4618BE62EE7D /* Targets Support Files */ = { - isa = PBXGroup; - children = ( - EFFD2E23EC66B46AAACF8921D4BB33F6 /* Pods-ExampleTests */, - ); - name = "Targets Support Files"; - sourceTree = ""; - }; - 954BCFEDD105B1C69BD59246182110B3 /* Support Files */ = { - isa = PBXGroup; - children = ( - F9EE523594F8F59E818AE09013D97B26 /* Apollo.modulemap */, - C1E7FD17E9DF9505367370BC48D4E400 /* Apollo.xcconfig */, - E5970ECF111CB0E4D500D988B7F7F9EB /* Apollo-dummy.m */, - 8231E933F2036997C124421FF6B3ADBC /* Apollo-Info.plist */, - AB55F31B9A6E601AA392FFDA8DFD0FDE /* Apollo-prefix.pch */, - AC1963D01CFF9BC54FE38C5936E792B1 /* Apollo-umbrella.h */, - ); - name = "Support Files"; - path = "../Target Support Files/Apollo"; - sourceTree = ""; - }; - BD5C6BC8BD33FD3A38AE096D24E6B339 /* Apollo */ = { - isa = PBXGroup; - children = ( - 64022C6041A0CA3A72182F217FEF131A /* Core */, - 954BCFEDD105B1C69BD59246182110B3 /* Support Files */, - ); - name = Apollo; - path = Apollo; - sourceTree = ""; - }; - CE580CEBF79F44818C4895EA91A9ED95 /* Pod */ = { - isa = PBXGroup; - children = ( - AFA574C23040442DABF1E27D12D75803 /* ApolloAlamofire.podspec */, - BA36ED0795AD536A71990EDA6245AD98 /* LICENSE */, - 1744369300E148EDB028501150D6DE00 /* README.md */, - ); - name = Pod; - sourceTree = ""; - }; - CF1408CF629C7361332E53B88F7BD30C = { - isa = PBXGroup; - children = ( - 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */, - E1E55A55B0BC234A82FD27AD25270C46 /* Development Pods */, - 3DB64DE0CD305423397F8407B66C98D7 /* Frameworks */, - ED90B31A1BD454CCE30CFB3AEBC81391 /* Pods */, - 3D61B0564D2EA856BC2EFDD7E82152F7 /* Products */, - 917609DAAB736B589ABD4618BE62EE7D /* Targets Support Files */, - ); - sourceTree = ""; - }; - D937E2B52ACA61FCE3EBFC284B06A3BE /* iOS */ = { - isa = PBXGroup; - children = ( - 946ADB5F075B7526EEEC3FCF4A88EE1E /* Foundation.framework */, - ); - name = iOS; - sourceTree = ""; - }; - E1E55A55B0BC234A82FD27AD25270C46 /* Development Pods */ = { - isa = PBXGroup; - children = ( - 30050025CE53A7A2A2D0FA844F70EE96 /* ApolloAlamofire */, - ); - name = "Development Pods"; - sourceTree = ""; - }; - ED90B31A1BD454CCE30CFB3AEBC81391 /* Pods */ = { - isa = PBXGroup; - children = ( - 7BF661162FBCAB6E4864272D6FF3D612 /* Alamofire */, - BD5C6BC8BD33FD3A38AE096D24E6B339 /* Apollo */, - ); - name = Pods; - sourceTree = ""; - }; - EFFD2E23EC66B46AAACF8921D4BB33F6 /* Pods-ExampleTests */ = { - isa = PBXGroup; - children = ( - 02E0D03D161FCA3F51FB13C2023F2CE3 /* Pods-ExampleTests.modulemap */, - 96EF831100D814BC04B00CDCBD42705D /* Pods-ExampleTests-acknowledgements.markdown */, - E05B5541C535417A1F792D29BF3EA582 /* Pods-ExampleTests-acknowledgements.plist */, - 5B88FE341015B15948D4B7230705AF8D /* Pods-ExampleTests-dummy.m */, - F6DA91FEF4E336235005FCA0445FE5C2 /* Pods-ExampleTests-frameworks.sh */, - 1C9611A0D410E095262A2095D8CB0A93 /* Pods-ExampleTests-Info.plist */, - 990D5081B4A254BD345E64157052CD10 /* Pods-ExampleTests-umbrella.h */, - 380A18E2C84AE29334F12DBE7811E2CB /* Pods-ExampleTests.debug.xcconfig */, - 287CAB3D9B2D3D365385E985CBCC616D /* Pods-ExampleTests.release.xcconfig */, - ); - name = "Pods-ExampleTests"; - path = "Target Support Files/Pods-ExampleTests"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 0FED7569EE1A2C99CFF99C5CC43E5DA2 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 7F83B0476EF971C2DDD4BF1E12E6CD30 /* ApolloAlamofire-umbrella.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2582784E4FA6A1AC5D23FC53AC3F6EE2 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - F7B74645E07C39771156A1FA413B98D4 /* Alamofire-umbrella.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 8681F152D4917EC69489F37244423CF2 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - D07C40C35E6D7667770BE02E7058B932 /* Apollo-umbrella.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - DAC3870F12AA20DF86FCD38DEFCD883C /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 3692130EDEAB70F20A7EA43CD4F92BA4 /* Pods-ExampleTests-umbrella.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 30EE3CABB612307A688C40B61BFA74CC /* Apollo */ = { - isa = PBXNativeTarget; - buildConfigurationList = EDB544C8EEC7EFBB69948BA3082B81D1 /* Build configuration list for PBXNativeTarget "Apollo" */; - buildPhases = ( - 8681F152D4917EC69489F37244423CF2 /* Headers */, - 85E38EB9A9E24418DDC0903AB2464BCE /* Sources */, - A2F77B8D67BB2A81DADE27AC4D16E9ED /* Frameworks */, - A7574E33FA1E960A24A9BDFC606B754A /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Apollo; - productName = Apollo; - productReference = 8F1FA46A3C7AA9081BA3650A49BDE9FE /* Apollo.framework */; - productType = "com.apple.product-type.framework"; - }; - 4432A314DF5F14FFF8809E319054F4AF /* Pods-ExampleTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 06747512BFB899CC9040894AF4DED575 /* Build configuration list for PBXNativeTarget "Pods-ExampleTests" */; - buildPhases = ( - DAC3870F12AA20DF86FCD38DEFCD883C /* Headers */, - 03E6A0D0708869870B20643F17070394 /* Sources */, - D24D6B4373C2422E12E665B936305651 /* Frameworks */, - F3885C0241E313D1717DE0468C2E44BF /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - D7900C54C073742FBE8C8E8CD24C8974 /* PBXTargetDependency */, - FAD5F7E634879E0535A10622F600D8C2 /* PBXTargetDependency */, - BBAE346B583FA528B4FAEBE09D423527 /* PBXTargetDependency */, - ); - name = "Pods-ExampleTests"; - productName = "Pods-ExampleTests"; - productReference = 630CABE8F692FCDBFD1B122A2D0CE388 /* Pods_ExampleTests.framework */; - productType = "com.apple.product-type.framework"; - }; - 6F3BE004A950C21FCFC67D7CF2961F40 /* ApolloAlamofire */ = { - isa = PBXNativeTarget; - buildConfigurationList = 0A11768426173DA9BE3AFE0D305FE2BC /* Build configuration list for PBXNativeTarget "ApolloAlamofire" */; - buildPhases = ( - 0FED7569EE1A2C99CFF99C5CC43E5DA2 /* Headers */, - 06F3B9765A66F06E3BD9A51B3E7B0421 /* Sources */, - 3D353BAE84BB35AF2B0B3EC00286EE6E /* Frameworks */, - D6153FE0F113300FFDDEE704C353AC18 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 963E75E41B33053C1951998FCDE16343 /* PBXTargetDependency */, - B2E3C55701E16D630DA3C2E4A5B324A2 /* PBXTargetDependency */, - ); - name = ApolloAlamofire; - productName = ApolloAlamofire; - productReference = 39C164E5D3807CA34B7ACD1B6C2302A9 /* ApolloAlamofire.framework */; - productType = "com.apple.product-type.framework"; - }; - EAAA1AD3A8A1B59AB91319EE40752C6D /* Alamofire */ = { - isa = PBXNativeTarget; - buildConfigurationList = E4A5194ABAF7A4780609E0E581DA6B54 /* Build configuration list for PBXNativeTarget "Alamofire" */; - buildPhases = ( - 2582784E4FA6A1AC5D23FC53AC3F6EE2 /* Headers */, - 2DDFD9AC10F181CD7130BDF5F9E0502B /* Sources */, - 090C1D63463ACF622287EFF9D5C9392D /* Frameworks */, - 473D3E892ABB6C798CFF290644259B34 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Alamofire; - productName = Alamofire; - productReference = 5D797E9A5C5782CE845840781FA1CC81 /* Alamofire.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - BFDFE7DC352907FC980B868725387E98 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 1100; - LastUpgradeCheck = 1100; - }; - buildConfigurationList = 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = CF1408CF629C7361332E53B88F7BD30C; - productRefGroup = 3D61B0564D2EA856BC2EFDD7E82152F7 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - EAAA1AD3A8A1B59AB91319EE40752C6D /* Alamofire */, - 30EE3CABB612307A688C40B61BFA74CC /* Apollo */, - 6F3BE004A950C21FCFC67D7CF2961F40 /* ApolloAlamofire */, - 4432A314DF5F14FFF8809E319054F4AF /* Pods-ExampleTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 473D3E892ABB6C798CFF290644259B34 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A7574E33FA1E960A24A9BDFC606B754A /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D9A6ED89859B7845939B3C864D7EA759 /* check-and-run-apollo-cli.sh in Resources */, - 0E57A0FCD033DCF2591EE89A5E9A95E0 /* check-and-run-apollo-codegen.sh in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - D6153FE0F113300FFDDEE704C353AC18 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - F3885C0241E313D1717DE0468C2E44BF /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 03E6A0D0708869870B20643F17070394 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D706082B53ACEEDFC2EBB068D2F5C14C /* Pods-ExampleTests-dummy.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 06F3B9765A66F06E3BD9A51B3E7B0421 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - CB830C3777A5C5452B0A1D208BF8E99C /* AlamofireTransport.swift in Sources */, - B773D9B5E1E6310D686366804877B4A0 /* ApolloAlamofire-dummy.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2DDFD9AC10F181CD7130BDF5F9E0502B /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 83956E20859CDBBE7BC38ABADE0170FB /* AFError.swift in Sources */, - 1945CD5D63A1C164AEAAA9A33E85571E /* Alamofire-dummy.m in Sources */, - BEE6B677416CA71C981D1D3F60B18C96 /* Alamofire.swift in Sources */, - D3D8C379C6E4FB487E5ABD6800AD7B7E /* DispatchQueue+Alamofire.swift in Sources */, - 1986B50C74F1697EA43F68335C93CEB3 /* MultipartFormData.swift in Sources */, - 3571F958A3907B3A806E62D50C2550D4 /* NetworkReachabilityManager.swift in Sources */, - 132E0F619E4338E5D1B27E4C72076B3F /* Notifications.swift in Sources */, - 0C5E11DE24DAA737704B355F5F2F3426 /* ParameterEncoding.swift in Sources */, - 98A929C8E9012AB167672714FFD2113C /* Request.swift in Sources */, - D65C254F5ABF2CB5ECEE50FE8F8E1A80 /* Response.swift in Sources */, - E3747EC31FCCA97D75A81FC700CF7E24 /* ResponseSerialization.swift in Sources */, - 64744C911253C3E01461FAD7C935C8D7 /* Result.swift in Sources */, - F13F2AA7F2E6D95A181CAB99B900D531 /* ServerTrustPolicy.swift in Sources */, - 2C61B040BA6A9A7AE66C4D9BA26D5520 /* SessionDelegate.swift in Sources */, - 931BBB8230A25161D5C37528A8F9FECF /* SessionManager.swift in Sources */, - AFC64B1097F7355FF423D6A73E9C7210 /* TaskDelegate.swift in Sources */, - 933FDA5970AA525D6CB92BFEBA2BAB4A /* Timeline.swift in Sources */, - 53791F5E5F07400F92CFDFC89A432305 /* Validation.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 85E38EB9A9E24418DDC0903AB2464BCE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - CB2C2AC79E10889EC840CD6C3D24F96F /* Apollo-dummy.m in Sources */, - C7BA21EB285B98FE70C39FC6BE8923B7 /* ApolloClient.swift in Sources */, - E54965381A172A8BA53D4049B7FEDD41 /* ApolloStore.swift in Sources */, - A95D757DE0D3A243A6B261524FE3584E /* AsynchronousOperation.swift in Sources */, - 9674E10F14B21179B45026979006FE19 /* Collections.swift in Sources */, - FFF1EA5D590D8EF4780539985010797F /* DataLoader.swift in Sources */, - 40EDBFE770257924149D1EB6C29C9B64 /* GraphQLDependencyTracker.swift in Sources */, - 30B7EC5CCBAFC80A2D721A50BAF1C938 /* GraphQLError.swift in Sources */, - 973F72124FAB66C4120931656A1D5EC5 /* GraphQLExecutor.swift in Sources */, - C774A69F0F79A828351A109548619CFE /* GraphQLInputValue.swift in Sources */, - B02D7FF97A812594E57E36998242D83F /* GraphQLOperation.swift in Sources */, - 261C5C30E9F8CA98AD23B3F4BE7C09D8 /* GraphQLQueryWatcher.swift in Sources */, - 7E89BB52104E5C9A071A9CC48B65AEF2 /* GraphQLResponse.swift in Sources */, - B751C06583B9F408F3C76410759CA6EA /* GraphQLResponseGenerator.swift in Sources */, - EECD898523E8110738B378422D93B69F /* GraphQLResult.swift in Sources */, - FC5B4DE6F6AD773481EABECF2AA4C6AC /* GraphQLResultAccumulator.swift in Sources */, - 95B16F88F11EA91821A745A488501F01 /* GraphQLResultNormalizer.swift in Sources */, - 9AA759B4D4311BCA2E01256C322C48C2 /* GraphQLSelectionSet.swift in Sources */, - 597D74F292EF51A7B0D14CE8D77287E7 /* GraphQLSelectionSetMapper.swift in Sources */, - 95680EC9226653178A302E6FEB244454 /* HTTPNetworkTransport.swift in Sources */, - 87E7EB3791F61374EFD8E63E4545FDB9 /* InMemoryNormalizedCache.swift in Sources */, - B35F5B7C07D5FBC9D33D561BD7DC8B01 /* JSON.swift in Sources */, - D96A02B8657B7BCB64C3211E44EF4825 /* JSONSerializationFormat.swift in Sources */, - 751A13CA1F2D6B41555E7C4D8586FACD /* JSONStandardTypeConversions.swift in Sources */, - AAD3E591C7836677D61E48ED1B067151 /* Locking.swift in Sources */, - E80A257C39F55BEDB0AF6F4AF035674E /* NetworkTransport.swift in Sources */, - 2139F3CD00F2798F57FA6B63A27C11F8 /* NormalizedCache.swift in Sources */, - D05B95B0818C14DBB6EDE674B636A995 /* Promise.swift in Sources */, - 8787F5B632CF9A0F302CED90AFB694F1 /* Record.swift in Sources */, - 120ABB8E306A42CB349EAE5C0C37ECCA /* RecordSet.swift in Sources */, - B0E3C5B5FFE47D8E0DF2E5F1E01D0D44 /* Result.swift in Sources */, - 05006B498A58D7F8A26BDAC0EA3FA64B /* ResultOrPromise.swift in Sources */, - 0F52D2EEF4D3CB5B8BCC8D33BD699BB6 /* Utilities.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 963E75E41B33053C1951998FCDE16343 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = Alamofire; - target = EAAA1AD3A8A1B59AB91319EE40752C6D /* Alamofire */; - targetProxy = FB56DDB9912324F872499E52876EA737 /* PBXContainerItemProxy */; - }; - B2E3C55701E16D630DA3C2E4A5B324A2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = Apollo; - target = 30EE3CABB612307A688C40B61BFA74CC /* Apollo */; - targetProxy = DF8663B36CBECCF976ABC5C2E43496AE /* PBXContainerItemProxy */; - }; - BBAE346B583FA528B4FAEBE09D423527 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = ApolloAlamofire; - target = 6F3BE004A950C21FCFC67D7CF2961F40 /* ApolloAlamofire */; - targetProxy = ADD626D417891997410FCE696FD9B799 /* PBXContainerItemProxy */; - }; - D7900C54C073742FBE8C8E8CD24C8974 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = Alamofire; - target = EAAA1AD3A8A1B59AB91319EE40752C6D /* Alamofire */; - targetProxy = 3A563B588E67BA0299053645B77E9A0D /* PBXContainerItemProxy */; - }; - FAD5F7E634879E0535A10622F600D8C2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = Apollo; - target = 30EE3CABB612307A688C40B61BFA74CC /* Apollo */; - targetProxy = EBE9910CE30DA1BE956ADD2C83925D07 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 0F488026BE6F086F651B6CC168645494 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = C1E7FD17E9DF9505367370BC48D4E400 /* Apollo.xcconfig */; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/Apollo/Apollo-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Apollo/Apollo-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Apollo/Apollo.modulemap"; - PRODUCT_MODULE_NAME = Apollo; - PRODUCT_NAME = Apollo; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - 427CC76C4A0D2313B395E0BB95F76060 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = D69587845CF50A79413B679C790F38B9 /* Alamofire.xcconfig */; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/Alamofire/Alamofire-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Alamofire/Alamofire-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Alamofire/Alamofire.modulemap"; - PRODUCT_MODULE_NAME = Alamofire; - PRODUCT_NAME = Alamofire; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 496F0297D948F196F4B0696D9DC08B1E /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 451453CE82BFA2CB07FC5EBF16AD38EC /* ApolloAlamofire.xcconfig */; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/ApolloAlamofire/ApolloAlamofire-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/ApolloAlamofire/ApolloAlamofire-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/ApolloAlamofire/ApolloAlamofire.modulemap"; - PRODUCT_MODULE_NAME = ApolloAlamofire; - PRODUCT_NAME = ApolloAlamofire; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 4DC904D5D0011B5674C03A066E0A5840 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 287CAB3D9B2D3D365385E985CBCC616D /* Pods-ExampleTests.release.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Target Support Files/Pods-ExampleTests/Pods-ExampleTests-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; - MODULEMAP_FILE = "Target Support Files/Pods-ExampleTests/Pods-ExampleTests.modulemap"; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - 69C5AA646D377295511DD0B088CBACCC /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = C1E7FD17E9DF9505367370BC48D4E400 /* Apollo.xcconfig */; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/Apollo/Apollo-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Apollo/Apollo-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Apollo/Apollo.modulemap"; - PRODUCT_MODULE_NAME = Apollo; - PRODUCT_NAME = Apollo; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 8F17DC3A99F99FBAD606CE6963886315 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "POD_CONFIGURATION_RELEASE=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - STRIP_INSTALLED_PRODUCT = NO; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 5.0; - SYMROOT = "${SRCROOT}/../build"; - }; - name = Release; - }; - 916E0404255105F480DC4950B7625F7A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "POD_CONFIGURATION_DEBUG=1", - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - STRIP_INSTALLED_PRODUCT = NO; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - SYMROOT = "${SRCROOT}/../build"; - }; - name = Debug; - }; - 96C891B8697E2C73BABA85937639DFF2 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = D69587845CF50A79413B679C790F38B9 /* Alamofire.xcconfig */; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/Alamofire/Alamofire-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Alamofire/Alamofire-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Alamofire/Alamofire.modulemap"; - PRODUCT_MODULE_NAME = Alamofire; - PRODUCT_NAME = Alamofire; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - C39475861EB59B6B502776326CFDE1F2 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 451453CE82BFA2CB07FC5EBF16AD38EC /* ApolloAlamofire.xcconfig */; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/ApolloAlamofire/ApolloAlamofire-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/ApolloAlamofire/ApolloAlamofire-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/ApolloAlamofire/ApolloAlamofire.modulemap"; - PRODUCT_MODULE_NAME = ApolloAlamofire; - PRODUCT_NAME = ApolloAlamofire; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - EFEF6D24668A33CF82AF223AACD8672F /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 380A18E2C84AE29334F12DBE7811E2CB /* Pods-ExampleTests.debug.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Target Support Files/Pods-ExampleTests/Pods-ExampleTests-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; - MODULEMAP_FILE = "Target Support Files/Pods-ExampleTests/Pods-ExampleTests.modulemap"; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 06747512BFB899CC9040894AF4DED575 /* Build configuration list for PBXNativeTarget "Pods-ExampleTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - EFEF6D24668A33CF82AF223AACD8672F /* Debug */, - 4DC904D5D0011B5674C03A066E0A5840 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 0A11768426173DA9BE3AFE0D305FE2BC /* Build configuration list for PBXNativeTarget "ApolloAlamofire" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 496F0297D948F196F4B0696D9DC08B1E /* Debug */, - C39475861EB59B6B502776326CFDE1F2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 916E0404255105F480DC4950B7625F7A /* Debug */, - 8F17DC3A99F99FBAD606CE6963886315 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - E4A5194ABAF7A4780609E0E581DA6B54 /* Build configuration list for PBXNativeTarget "Alamofire" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 427CC76C4A0D2313B395E0BB95F76060 /* Debug */, - 96C891B8697E2C73BABA85937639DFF2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - EDB544C8EEC7EFBB69948BA3082B81D1 /* Build configuration list for PBXNativeTarget "Apollo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 69C5AA646D377295511DD0B088CBACCC /* Debug */, - 0F488026BE6F086F651B6CC168645494 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = BFDFE7DC352907FC980B868725387E98 /* Project object */; -} diff --git a/Example/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/Example/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Example/Pods/Pods.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/Pods/Pods.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Example/Pods/Pods.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/ApolloAlamofire.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/ApolloAlamofire.xcscheme deleted file mode 100644 index 6bb0818..0000000 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/ApolloAlamofire.xcscheme +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/Pods/Target Support Files/Alamofire/Alamofire-Info.plist b/Example/Pods/Target Support Files/Alamofire/Alamofire-Info.plist deleted file mode 100644 index b287f84..0000000 --- a/Example/Pods/Target Support Files/Alamofire/Alamofire-Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 4.8.2 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m b/Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m deleted file mode 100644 index a6c4594..0000000 --- a/Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m +++ /dev/null @@ -1,5 +0,0 @@ -#import -@interface PodsDummy_Alamofire : NSObject -@end -@implementation PodsDummy_Alamofire -@end diff --git a/Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch b/Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch deleted file mode 100644 index beb2a24..0000000 --- a/Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - diff --git a/Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h b/Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h deleted file mode 100644 index 00014e3..0000000 --- a/Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - - -FOUNDATION_EXPORT double AlamofireVersionNumber; -FOUNDATION_EXPORT const unsigned char AlamofireVersionString[]; - diff --git a/Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap b/Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap deleted file mode 100644 index d1f125f..0000000 --- a/Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module Alamofire { - umbrella header "Alamofire-umbrella.h" - - export * - module * { export * } -} diff --git a/Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig b/Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig deleted file mode 100644 index 12a1450..0000000 --- a/Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig +++ /dev/null @@ -1,9 +0,0 @@ -CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Alamofire -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_ROOT = ${SRCROOT} -PODS_TARGET_SRCROOT = ${PODS_ROOT}/Alamofire -PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} -SKIP_INSTALL = YES diff --git a/Example/Pods/Target Support Files/Alamofire/Info.plist b/Example/Pods/Target Support Files/Alamofire/Info.plist deleted file mode 100644 index 2aba7e5..0000000 --- a/Example/Pods/Target Support Files/Alamofire/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 4.7.3 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/Apollo/Apollo-Info.plist b/Example/Pods/Target Support Files/Apollo/Apollo-Info.plist deleted file mode 100644 index 0a7e38b..0000000 --- a/Example/Pods/Target Support Files/Apollo/Apollo-Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 0.10.1 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/Apollo/Apollo-dummy.m b/Example/Pods/Target Support Files/Apollo/Apollo-dummy.m deleted file mode 100644 index 843221b..0000000 --- a/Example/Pods/Target Support Files/Apollo/Apollo-dummy.m +++ /dev/null @@ -1,5 +0,0 @@ -#import -@interface PodsDummy_Apollo : NSObject -@end -@implementation PodsDummy_Apollo -@end diff --git a/Example/Pods/Target Support Files/Apollo/Apollo-prefix.pch b/Example/Pods/Target Support Files/Apollo/Apollo-prefix.pch deleted file mode 100644 index beb2a24..0000000 --- a/Example/Pods/Target Support Files/Apollo/Apollo-prefix.pch +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - diff --git a/Example/Pods/Target Support Files/Apollo/Apollo-umbrella.h b/Example/Pods/Target Support Files/Apollo/Apollo-umbrella.h deleted file mode 100644 index ae2de99..0000000 --- a/Example/Pods/Target Support Files/Apollo/Apollo-umbrella.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - - -FOUNDATION_EXPORT double ApolloVersionNumber; -FOUNDATION_EXPORT const unsigned char ApolloVersionString[]; - diff --git a/Example/Pods/Target Support Files/Apollo/Apollo.modulemap b/Example/Pods/Target Support Files/Apollo/Apollo.modulemap deleted file mode 100644 index 008f0e5..0000000 --- a/Example/Pods/Target Support Files/Apollo/Apollo.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module Apollo { - umbrella header "Apollo-umbrella.h" - - export * - module * { export * } -} diff --git a/Example/Pods/Target Support Files/Apollo/Apollo.xcconfig b/Example/Pods/Target Support Files/Apollo/Apollo.xcconfig deleted file mode 100644 index 3b6b5ce..0000000 --- a/Example/Pods/Target Support Files/Apollo/Apollo.xcconfig +++ /dev/null @@ -1,9 +0,0 @@ -CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Apollo -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_ROOT = ${SRCROOT} -PODS_TARGET_SRCROOT = ${PODS_ROOT}/Apollo -PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} -SKIP_INSTALL = YES diff --git a/Example/Pods/Target Support Files/Apollo/Info.plist b/Example/Pods/Target Support Files/Apollo/Info.plist deleted file mode 100644 index b8a90bb..0000000 --- a/Example/Pods/Target Support Files/Apollo/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 0.9.3 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-Info.plist b/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-Info.plist deleted file mode 100644 index 324eeb2..0000000 --- a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 0.5.0 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-dummy.m b/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-dummy.m deleted file mode 100644 index 6d76651..0000000 --- a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-dummy.m +++ /dev/null @@ -1,5 +0,0 @@ -#import -@interface PodsDummy_ApolloAlamofire : NSObject -@end -@implementation PodsDummy_ApolloAlamofire -@end diff --git a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-prefix.pch b/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-prefix.pch deleted file mode 100644 index beb2a24..0000000 --- a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-prefix.pch +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - diff --git a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-umbrella.h b/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-umbrella.h deleted file mode 100644 index 13be29f..0000000 --- a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire-umbrella.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - - -FOUNDATION_EXPORT double ApolloAlamofireVersionNumber; -FOUNDATION_EXPORT const unsigned char ApolloAlamofireVersionString[]; - diff --git a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire.modulemap b/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire.modulemap deleted file mode 100644 index e959797..0000000 --- a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module ApolloAlamofire { - umbrella header "ApolloAlamofire-umbrella.h" - - export * - module * { export * } -} diff --git a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire.xcconfig b/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire.xcconfig deleted file mode 100644 index 18fe7f4..0000000 --- a/Example/Pods/Target Support Files/ApolloAlamofire/ApolloAlamofire.xcconfig +++ /dev/null @@ -1,10 +0,0 @@ -CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/ApolloAlamofire -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/Apollo" -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_ROOT = ${SRCROOT} -PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. -PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} -SKIP_INSTALL = YES diff --git a/Example/Pods/Target Support Files/ApolloAlamofire/Info.plist b/Example/Pods/Target Support Files/ApolloAlamofire/Info.plist deleted file mode 100644 index f92230d..0000000 --- a/Example/Pods/Target Support Files/ApolloAlamofire/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 0.3.0 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-Info.plist b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-Info.plist deleted file mode 100644 index 2243fe6..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0.0 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-acknowledgements.markdown b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-acknowledgements.markdown deleted file mode 100644 index 529cd86..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-acknowledgements.markdown +++ /dev/null @@ -1,74 +0,0 @@ -# Acknowledgements -This application makes use of the following third party libraries: - -## Alamofire - -Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -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. - - -## Apollo - -The MIT License (MIT) - -Copyright (c) 2016-2017 Meteor Development Group, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -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. - - -## ApolloAlamofire - -Copyright (c) 2018 Max Desiatov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -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. - -Generated by CocoaPods - https://cocoapods.org diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-acknowledgements.plist b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-acknowledgements.plist deleted file mode 100644 index 45f88b0..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-acknowledgements.plist +++ /dev/null @@ -1,118 +0,0 @@ - - - - - PreferenceSpecifiers - - - FooterText - This application makes use of the following third party libraries: - Title - Acknowledgements - Type - PSGroupSpecifier - - - FooterText - Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -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 - MIT - Title - Alamofire - Type - PSGroupSpecifier - - - FooterText - The MIT License (MIT) - -Copyright (c) 2016-2017 Meteor Development Group, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -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 - MIT - Title - Apollo - Type - PSGroupSpecifier - - - FooterText - Copyright (c) 2018 Max Desiatov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -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 - MIT - Title - ApolloAlamofire - Type - PSGroupSpecifier - - - FooterText - Generated by CocoaPods - https://cocoapods.org - Title - - Type - PSGroupSpecifier - - - StringsTable - Acknowledgements - Title - Acknowledgements - - diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-dummy.m b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-dummy.m deleted file mode 100644 index c0024d5..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-dummy.m +++ /dev/null @@ -1,5 +0,0 @@ -#import -@interface PodsDummy_Pods_ExampleTests : NSObject -@end -@implementation PodsDummy_Pods_ExampleTests -@end diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-frameworks.sh b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-frameworks.sh deleted file mode 100755 index 01ebd8b..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-frameworks.sh +++ /dev/null @@ -1,175 +0,0 @@ -#!/bin/sh -set -e -set -u -set -o pipefail - -function on_error { - echo "$(realpath -mq "${0}"):$1: error: Unexpected failure" -} -trap 'on_error $LINENO' ERR - -if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then - # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy - # frameworks to, so exit 0 (signalling the script phase was successful). - exit 0 -fi - -echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" -mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" - -COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" -SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" - -# Used as a return value for each invocation of `strip_invalid_archs` function. -STRIP_BINARY_RETVAL=0 - -# This protects against multiple targets copying the same framework dependency at the same time. The solution -# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html -RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") - -# Copies and strips a vendored framework -install_framework() -{ - if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then - local source="${BUILT_PRODUCTS_DIR}/$1" - elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then - local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" - elif [ -r "$1" ]; then - local source="$1" - fi - - local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" - - if [ -L "${source}" ]; then - echo "Symlinked..." - source="$(readlink "${source}")" - fi - - # Use filter instead of exclude so missing patterns don't throw errors. - echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" - rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" - - local basename - basename="$(basename -s .framework "$1")" - binary="${destination}/${basename}.framework/${basename}" - - if ! [ -r "$binary" ]; then - binary="${destination}/${basename}" - elif [ -L "${binary}" ]; then - echo "Destination binary is symlinked..." - dirname="$(dirname "${binary}")" - binary="${dirname}/$(readlink "${binary}")" - fi - - # Strip invalid architectures so "fat" simulator / device frameworks work on device - if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then - strip_invalid_archs "$binary" - fi - - # Resign the code if required by the build settings to avoid unstable apps - code_sign_if_enabled "${destination}/$(basename "$1")" - - # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. - if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then - local swift_runtime_libs - swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) - for lib in $swift_runtime_libs; do - echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" - rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" - code_sign_if_enabled "${destination}/${lib}" - done - fi -} - -# Copies and strips a vendored dSYM -install_dsym() { - local source="$1" - if [ -r "$source" ]; then - # Copy the dSYM into a the targets temp dir. - echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" - rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" - - local basename - basename="$(basename -s .framework.dSYM "$source")" - binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" - - # Strip invalid architectures so "fat" simulator / device frameworks work on device - if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then - strip_invalid_archs "$binary" - fi - - if [[ $STRIP_BINARY_RETVAL == 1 ]]; then - # Move the stripped file into its final destination. - echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" - rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" - else - # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. - touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" - fi - fi -} - -# Copies the bcsymbolmap files of a vendored framework -install_bcsymbolmap() { - local bcsymbolmap_path="$1" - local destination="${BUILT_PRODUCTS_DIR}" - echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"" - rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}" -} - -# Signs a framework with the provided identity -code_sign_if_enabled() { - if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then - # Use the current code_sign_identity - echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" - local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" - - if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then - code_sign_cmd="$code_sign_cmd &" - fi - echo "$code_sign_cmd" - eval "$code_sign_cmd" - fi -} - -# Strip invalid architectures -strip_invalid_archs() { - binary="$1" - # Get architectures for current target binary - binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" - # Intersect them with the architectures we are building for - intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" - # If there are no archs supported by this binary then warn the user - if [[ -z "$intersected_archs" ]]; then - echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." - STRIP_BINARY_RETVAL=0 - return - fi - stripped="" - for arch in $binary_archs; do - if ! [[ "${ARCHS}" == *"$arch"* ]]; then - # Strip non-valid architectures in-place - lipo -remove "$arch" -output "$binary" "$binary" - stripped="$stripped $arch" - fi - done - if [[ "$stripped" ]]; then - echo "Stripped $binary of architectures:$stripped" - fi - STRIP_BINARY_RETVAL=1 -} - - -if [[ "$CONFIGURATION" == "Debug" ]]; then - install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework" - install_framework "${BUILT_PRODUCTS_DIR}/Apollo/Apollo.framework" - install_framework "${BUILT_PRODUCTS_DIR}/ApolloAlamofire/ApolloAlamofire.framework" -fi -if [[ "$CONFIGURATION" == "Release" ]]; then - install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework" - install_framework "${BUILT_PRODUCTS_DIR}/Apollo/Apollo.framework" - install_framework "${BUILT_PRODUCTS_DIR}/ApolloAlamofire/ApolloAlamofire.framework" -fi -if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then - wait -fi diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-umbrella.h b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-umbrella.h deleted file mode 100644 index b12f2ef..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests-umbrella.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - - -FOUNDATION_EXPORT double Pods_ExampleTestsVersionNumber; -FOUNDATION_EXPORT const unsigned char Pods_ExampleTestsVersionString[]; - diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.debug.xcconfig b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.debug.xcconfig deleted file mode 100644 index d2550e5..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.debug.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/Apollo" "${PODS_CONFIGURATION_BUILD_DIR}/ApolloAlamofire" -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Apollo/Apollo.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ApolloAlamofire/ApolloAlamofire.framework/Headers" -LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' -OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "Apollo" -framework "ApolloAlamofire" -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_PODFILE_DIR_PATH = ${SRCROOT}/. -PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.modulemap b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.modulemap deleted file mode 100644 index 08843bd..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module Pods_ExampleTests { - umbrella header "Pods-ExampleTests-umbrella.h" - - export * - module * { export * } -} diff --git a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.release.xcconfig b/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.release.xcconfig deleted file mode 100644 index d2550e5..0000000 --- a/Example/Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.release.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/Apollo" "${PODS_CONFIGURATION_BUILD_DIR}/ApolloAlamofire" -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Apollo/Apollo.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ApolloAlamofire/ApolloAlamofire.framework/Headers" -LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' -OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "Apollo" -framework "ApolloAlamofire" -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_PODFILE_DIR_PATH = ${SRCROOT}/. -PODS_ROOT = ${SRCROOT}/Pods diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..e1318f8 --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +#/bin/bash + +set -e +set -o pipefail + +xcodebuild test -enableCodeCoverage YES \ + -workspace Example/ApolloAlamofire.xcworkspace -scheme Example \ + -sdk iphonesimulator -destination "$TEST_DEVICE" | xcpretty +pod lib lint --allow-warnings