Skip to content

Commit c47f27b

Browse files
author
Ruben Nine
committed
Removing dependency on AlamoFire.
1 parent c49d3ea commit c47f27b

35 files changed

+556
-542
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Change Log
22
==========
33

4+
Version 2.6.0 *TBD*
5+
----------------------------
6+
- Removed dependency on `AlamoFire`.
7+
48
Version 2.5.2 *(2020-11-12)*
59
----------------------------
610
- Changed transformable store request to use GET instead of POST.

FilestackSDK.podspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ Pod::Spec.new do |spec|
1414
spec.public_header_files = 'Sources/**/*.h'
1515

1616
spec.swift_versions = [4.2, 5.2]
17-
spec.dependency 'Alamofire', '~> 4.9'
1817
end

FilestackSDK.xcodeproj/project.pbxproj

Lines changed: 152 additions & 114 deletions
Large diffs are not rendered by default.

FilestackSDK.xcodeproj/xcshareddata/xcschemes/FilestackSDK.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1200"
3+
LastUpgradeVersion = "1240"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Package.resolved

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ let package = Package(
1414
),
1515
],
1616
dependencies: [
17-
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: Version(4, 9, 0))),
1817
.package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", .upToNextMajor(from: Version(9, 0, 0)))
1918
],
2019
targets: [
2120
.target(
2221
name: "FilestackSDK",
23-
dependencies: ["Alamofire", "ObjcDefs"],
22+
dependencies: ["ObjcDefs"],
2423
resources: [
2524
.copy("VERSION")
2625
]

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ platform :ios, '11.0'
3434
use_frameworks!
3535

3636
target '<Your Target Name>' do
37-
pod 'FilestackSDK', '~> 2.5.2'
37+
pod 'FilestackSDK', '~> 2.6.0'
3838
end
3939
```
4040

@@ -57,9 +57,9 @@ $ brew install carthage
5757

5858
To integrate FilestackSDK into your Xcode project using Carthage, specify it in your `Cartfile`:
5959

60-
`github "filestack/filestack-swift" ~> 2.5.2`
60+
`github "filestack/filestack-swift" ~> 2.6.0`
6161

62-
Run `carthage update` to build the framework and drag the built `FilestackSDK.framework` into your Xcode project. Additionally, add `Alamofire.framework` to the embedded frameworks build phase of your app's target.
62+
Run `carthage update` to build the framework and drag the built `FilestackSDK.framework` into your Xcode project.
6363

6464
### Swift Package Manager
6565

@@ -69,7 +69,7 @@ Alternatively, if you are adding `FilestackSDK` to your own Swift Package, decla
6969

7070
```swift
7171
dependencies: [
72-
.package(url: "https://github.com/filestack/filestack-swift.git", .upToNextMajor(from: "2.5.2"))
72+
.package(url: "https://github.com/filestack/filestack-swift.git", .upToNextMajor(from: "2.6.0"))
7373
]
7474
```
7575

@@ -87,7 +87,6 @@ Add FilestackSDK and its dependencies as git submodules by running the following
8787

8888
```shell
8989
$ git submodule add https://github.com/filestack/filestack-swift.git
90-
$ git submodule add https://github.com/Alamofire/Alamofire.git
9190
```
9291

9392
Open the new `filestack-swift` folder, and drag the `FilestackSDK.xcodeproj` into the Project Navigator of your application's Xcode project.
@@ -101,8 +100,6 @@ In the tab bar at the top of that window, open the "General" panel.
101100

102101
Click on the + button under the "Embedded Binaries" section and choose the `FilestackSDK.framework` for iOS.
103102

104-
Repeat the same process for adding `Alamofire`.
105-
106103
## Usage
107104

108105
<details>

Sources/FilestackSDK/Internal/Extensions/NetworkingServiceWithBaseURL+buildURL.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// Copyright © 2019 Filestack. All rights reserved.
77
//
88

9-
import Alamofire
109
import Foundation
1110

1211
extension NetworkingServiceWithBaseURL {
@@ -23,7 +22,9 @@ extension NetworkingServiceWithBaseURL {
2322

2423
guard var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return nil }
2524

26-
urlComponents.queryItems = queryItems
25+
if let queryItems = queryItems {
26+
urlComponents.queryItems = queryItems
27+
}
2728

2829
if let security = security {
2930
if urlComponents.queryItems == nil {
@@ -34,10 +35,10 @@ extension NetworkingServiceWithBaseURL {
3435
urlComponents.queryItems?.append(URLQueryItem(name: "signature", value: security.signature))
3536
}
3637

37-
return try? urlComponents.asURL()
38+
return urlComponents.url
3839
}
3940

40-
func request(url: URL, method: HTTPMethod, parameters: [String: Any]? = nil, headers: HTTPHeaders? = nil) -> DataRequest? {
41-
return sessionManager.request(url, method: method, parameters: parameters, headers: headers)
41+
func parametersToQueryItems(parameters: [String: Any]) -> [URLQueryItem] {
42+
return parameters.compactMap { URLQueryItem(name: $0.key, value: $0.value as? String) }
4243
}
4344
}

Sources/FilestackSDK/Internal/Extensions/SessionManager+filestackDefault.swift renamed to Sources/FilestackSDK/Internal/Extensions/URLSession+filestackDefault.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
//
2-
// SessionManager+filestackDefault.swift
2+
// URLSession+filestackDefault.swift
33
// FilestackSDK
44
//
55
// Created by Ruben Nine on 7/5/17.
66
// Copyright © 2017 Filestack. All rights reserved.
77
//
88

9-
import Alamofire
109
import Foundation
1110

1211
#if SWIFT_PACKAGE
1312
#else
1413
private class BundleFinder {}
1514
#endif
1615

17-
extension SessionManager {
18-
static func filestack(background: Bool = false) -> SessionManager {
16+
extension URLSession {
17+
static func filestack(background: Bool = false, delegate: URLSessionDelegate? = nil) -> URLSession {
1918
let configuration: URLSessionConfiguration
2019

2120
if background {
@@ -30,15 +29,15 @@ extension SessionManager {
3029
configuration.httpShouldUsePipelining = true
3130
configuration.httpAdditionalHeaders = customHTTPHeaders
3231

33-
return SessionManager(configuration: configuration)
32+
return URLSession(configuration: configuration, delegate: delegate, delegateQueue: nil)
3433
}
3534
}
3635

3736
// MARK: - Private Functions
3837

39-
private extension SessionManager {
40-
static var customHTTPHeaders: HTTPHeaders {
41-
var defaultHeaders = SessionManager.defaultHTTPHeaders
38+
private extension URLSession {
39+
static var customHTTPHeaders: [String: String] {
40+
var defaultHeaders: [String: String] = [:]
4241

4342
defaultHeaders["User-Agent"] = "filestack-swift \(shortVersionString)"
4443
defaultHeaders["Filestack-Source"] = "Swift-\(shortVersionString)"

Sources/FilestackSDK/Internal/Operations/CommitPartUploadOperation.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// Copyright © 2017 Filestack. All rights reserved.
77
//
88

9-
import Alamofire
109
import Foundation
1110

1211
class CommitPartUploadOperation: BaseOperation<HTTPURLResponse> {
@@ -56,17 +55,12 @@ private extension CommitPartUploadOperation {
5655

5756
retrier = .init(attempts: Defaults.maxRetries, label: uploadURL.relativePath) { (semaphore) -> HTTPURLResponse? in
5857
var httpURLResponse: HTTPURLResponse?
59-
let headers: HTTPHeaders = ["Content-Type": "application/json"]
58+
let headers = ["Content-Type": "application/json"]
6059

61-
guard
62-
let payload = self.payload(),
63-
let request = UploadService.shared.upload(data: payload, to: uploadURL, method: .post, headers: headers)
64-
else {
65-
return nil
66-
}
60+
guard let payload = self.payload() else { return nil }
6761

68-
request.responseJSON { (response) in
69-
httpURLResponse = response.response
62+
UploadService.shared.upload(data: payload, to: uploadURL, method: "POST", headers: headers) { (data, response, error) in
63+
httpURLResponse = response as? HTTPURLResponse
7064
semaphore.signal()
7165
}
7266

0 commit comments

Comments
 (0)