Skip to content

Commit f8cd539

Browse files
committed
Remove Alamofire dependency from PIALibrary and PIA VPN
1 parent 2f69caf commit f8cd539

11 files changed

Lines changed: 27 additions & 133 deletions

File tree

LocalPackages/PIALibrary/Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ let package = Package(
3333
.package(url: "https://github.com/Orderella/PopupDialog.git", branch: "master"),
3434
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver.git", from: "1.9.0"),
3535
.package(url: "https://github.com/ashleymills/Reachability.swift.git", from: "4.3.0"),
36-
.package(url: "https://github.com/Alamofire/Alamofire.git", exact: "5.0.1"),
3736
.package(url: "git@github.com:pia-foss/mobile-ios-networking.git", exact: "1.3.1")
3837
],
3938
targets: [
@@ -43,7 +42,6 @@ let package = Package(
4342
"SwiftyBeaver",
4443
"Gloss",
4544
"PIALibraryUtilObjC",
46-
"Alamofire",
4745
.product(name: "PopupDialog", package: "PopupDialog", condition: .when(platforms: [.iOS])),
4846
.product(name: "SwiftEntryKit", package: "SwiftEntryKit", condition: .when(platforms: [.iOS])),
4947
.product(name: "Lottie", package: "lottie-ios"),

LocalPackages/PIALibrary/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ This project is licensed under the [MIT (Expat) license](https://choosealicense.
304304

305305
- SwiftyBeaver - © 2015 Sebastian Kreutzberger
306306
- Gloss - © 2017 Harlan Kellaway
307-
- Alamofire - © 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
308307
- ReachabilitySwift - © 2016 Ashley Mills
309308
- TunnelKit - © 2018 - Present Davide de Rosa (https://github.com/passepartoutvpn/tunnelkit) - TunnelKit is not MIT software and remains under the terms of the GPL license (https://github.com/passepartoutvpn/tunnelkit/blob/master/LICENSE)
310309

LocalPackages/PIALibrary/Sources/PIALibrary/Client+Configuration.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
//
2222

2323
import Foundation
24-
import Alamofire
2524

2625
@available(tvOS 17.0, *)
2726
extension Client {
@@ -147,8 +146,6 @@ extension Client {
147146

148147
public let maceDelay: Int
149148

150-
let sessionManager: Session
151-
152149
// MARK: VPN
153150

154151
private var availableVPNProfiles: [VPNProfile]
@@ -253,12 +250,6 @@ extension Client {
253250
macePort = 1111
254251
maceDelay = 5000
255252

256-
let urlscfg = URLSessionConfiguration.default
257-
urlscfg.timeoutIntervalForRequest = Double(webTimeout) / 1000.0
258-
urlscfg.timeoutIntervalForResource = Double(webTimeout) / 1000.0
259-
urlscfg.urlCache = nil
260-
sessionManager = Session(configuration: urlscfg)
261-
262253
#if os(iOS) || os(tvOS)
263254
inAppPlans = [:]
264255
eligibleForTrial = true

LocalPackages/PIALibrary/Sources/PIALibrary/WebServices/PIAWebServices.swift

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
//
2222

2323
import Foundation
24-
import Alamofire
2524
import Gloss
2625
import SwiftyBeaver
2726
import regions
@@ -537,59 +536,3 @@ class PIAWebServices: WebServices, ConfigurationAccess {
537536
}
538537
}
539538
}
540-
541-
typealias HandlerType<T> = (T?, Int?, Error?) -> Void
542-
543-
private protocol RequestExecutor {
544-
func execute(_ method: HTTPMethod, _ url: URL, _ request: DataRequest)
545-
}
546-
547-
private class DataRequestExecutor: RequestExecutor {
548-
let completionHandler: HandlerType<Data>
549-
550-
init(_ completionHandler: @escaping HandlerType<Data>) {
551-
self.completionHandler = completionHandler
552-
}
553-
554-
func execute(_ method: HTTPMethod, _ url: URL, _ request: DataRequest) {
555-
request.responseData { (response) in
556-
let status = response.response?.statusCode
557-
if let error = response.error {
558-
log.error("Request failed: \(method) \"\(url)\" -> \(error)")
559-
self.completionHandler(nil, status, error)
560-
return
561-
}
562-
guard let data = response.value else {
563-
self.completionHandler(nil, status, ClientError.malformedResponseData)
564-
return
565-
}
566-
log.debug("Response: \(data)")
567-
self.completionHandler(data, status, nil)
568-
}
569-
}
570-
}
571-
572-
private class JSONRequestExecutor: RequestExecutor {
573-
let completionHandler: HandlerType<JSON>
574-
575-
init(_ completionHandler: @escaping HandlerType<JSON>) {
576-
self.completionHandler = completionHandler
577-
}
578-
579-
func execute(_ method: HTTPMethod, _ url: URL, _ request: DataRequest) {
580-
request.validate(contentType: ["application/json"]).responseJSON { (response) in
581-
let status = response.response?.statusCode
582-
if let error = response.error {
583-
log.error("Request failed: \(method) \"\(url)\" -> \(error)")
584-
self.completionHandler(nil, status, error)
585-
return
586-
}
587-
guard let json = response.value as? [String: Any] else {
588-
self.completionHandler(nil, status, ClientError.malformedResponseData)
589-
return
590-
}
591-
log.debug("Response: \(json)")
592-
self.completionHandler(json, status, nil)
593-
}
594-
}
595-
}

PIA VPN-tvOS/Resources/Licences.plist

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@
1212
<key>LicenseURL</key>
1313
<string>https://raw.githubusercontent.com/ashleymills/Reachability.swift/master/LICENSE</string>
1414
</dict>
15-
<dict>
16-
<key>Name</key>
17-
<string>Alamofire</string>
18-
<key>Copyright</key>
19-
<string>Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)</string>
20-
<key>LicenseURL</key>
21-
<string>https://raw.githubusercontent.com/Alamofire/Alamofire/master/LICENSE</string>
22-
</dict>
2315
<dict>
2416
<key>Name</key>
2517
<string>TunnelKit</string>

PIA VPN.xcodeproj/project.pbxproj

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@
5151
AA36CDCC28A673C900180A33 /* GradientProgressBar in Frameworks */ = {isa = PBXBuildFile; productRef = AA36CDCB28A673C900180A33 /* GradientProgressBar */; };
5252
AA36CDCF28A6746500180A33 /* SideMenu in Frameworks */ = {isa = PBXBuildFile; productRef = AA36CDCE28A6746500180A33 /* SideMenu */; };
5353
AA36CDDB28A6860F00180A33 /* TweetNacl in Frameworks */ = {isa = PBXBuildFile; productRef = AA36CDDA28A6860F00180A33 /* TweetNacl */; };
54-
AA36CDDE28A6878000180A33 /* AlamofireImage in Frameworks */ = {isa = PBXBuildFile; productRef = AA36CDDD28A6878000180A33 /* AlamofireImage */; };
5554
AABF826D28AD185E00CDAC64 /* TweetNacl in Frameworks */ = {isa = PBXBuildFile; productRef = AABF826C28AD185E00CDAC64 /* TweetNacl */; };
5655
AABF826F28AD187800CDAC64 /* Popover in Frameworks */ = {isa = PBXBuildFile; productRef = AABF826E28AD187800CDAC64 /* Popover */; };
57-
AABF827128AD188700CDAC64 /* AlamofireImage in Frameworks */ = {isa = PBXBuildFile; productRef = AABF827028AD188700CDAC64 /* AlamofireImage */; };
5856
AABF827328AE2FF500CDAC64 /* GradientProgressBar in Frameworks */ = {isa = PBXBuildFile; productRef = AABF827228AE2FF500CDAC64 /* GradientProgressBar */; };
5957
AABF827528AE2FFE00CDAC64 /* SideMenu in Frameworks */ = {isa = PBXBuildFile; productRef = AABF827428AE2FFE00CDAC64 /* SideMenu */; };
6058
AABF827628AE302300CDAC64 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD606AB921C7A17900E0781D /* NetworkExtension.framework */; };
@@ -481,7 +479,6 @@
481479
buildActionMask = 2147483647;
482480
files = (
483481
3F7B4C8D2EE7333300EE1F4C /* PIADesignSystem in Frameworks */,
484-
AABF827128AD188700CDAC64 /* AlamofireImage in Frameworks */,
485482
AABF827628AE302300CDAC64 /* NetworkExtension.framework in Frameworks */,
486483
0EE220571F4EF307002805AE /* Security.framework in Frameworks */,
487484
0EE220581F4EF307002805AE /* SystemConfiguration.framework in Frameworks */,
@@ -524,7 +521,6 @@
524521
AA36CDCC28A673C900180A33 /* GradientProgressBar in Frameworks */,
525522
AA36CDCF28A6746500180A33 /* SideMenu in Frameworks */,
526523
AA36CDBB28A6622A00180A33 /* TweetNacl in Frameworks */,
527-
AA36CDDE28A6878000180A33 /* AlamofireImage in Frameworks */,
528524
2909869018566430002D9687 /* Security.framework in Frameworks */,
529525
299E58511856BD31004CFD63 /* SystemConfiguration.framework in Frameworks */,
530526
299E585F1856C6EE004CFD63 /* libz.dylib in Frameworks */,
@@ -741,7 +737,6 @@
741737
packageProductDependencies = (
742738
AABF826C28AD185E00CDAC64 /* TweetNacl */,
743739
AABF826E28AD187800CDAC64 /* Popover */,
744-
AABF827028AD188700CDAC64 /* AlamofireImage */,
745740
AABF827228AE2FF500CDAC64 /* GradientProgressBar */,
746741
AABF827428AE2FFE00CDAC64 /* SideMenu */,
747742
AABF827728AE333200CDAC64 /* DZNEmptyDataSet */,
@@ -820,7 +815,6 @@
820815
AA36CDC828A6733500180A33 /* DZNEmptyDataSet */,
821816
AA36CDCB28A673C900180A33 /* GradientProgressBar */,
822817
AA36CDCE28A6746500180A33 /* SideMenu */,
823-
AA36CDDD28A6878000180A33 /* AlamofireImage */,
824818
3F7B4C8A2EE7332B00EE1F4C /* PIADesignSystem */,
825819
3F7BD9B72EE8A09800EE1F4C /* PIALibrary */,
826820
);
@@ -1164,7 +1158,6 @@
11641158
AA36CDC728A6733500180A33 /* XCRemoteSwiftPackageReference "DZNEmptyDataSet" */,
11651159
AA36CDCA28A673C900180A33 /* XCRemoteSwiftPackageReference "GradientProgressBar" */,
11661160
AA36CDCD28A6746500180A33 /* XCRemoteSwiftPackageReference "SideMenu" */,
1167-
AA36CDDC28A6878000180A33 /* XCRemoteSwiftPackageReference "AlamofireImage" */,
11681161
35950B2F2ADD2877006F3CD9 /* XCRemoteSwiftPackageReference "Quick" */,
11691162
35950B322ADD2EE5006F3CD9 /* XCRemoteSwiftPackageReference "Nimble" */,
11701163
E548E1EE2C12383E001E9874 /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */,
@@ -2894,14 +2887,6 @@
28942887
version = 6.5.0;
28952888
};
28962889
};
2897-
AA36CDDC28A6878000180A33 /* XCRemoteSwiftPackageReference "AlamofireImage" */ = {
2898-
isa = XCRemoteSwiftPackageReference;
2899-
repositoryURL = "https://github.com/Alamofire/AlamofireImage.git";
2900-
requirement = {
2901-
kind = exactVersion;
2902-
version = 4.0.0;
2903-
};
2904-
};
29052890
E548E1EE2C12383E001E9874 /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
29062891
isa = XCRemoteSwiftPackageReference;
29072892
repositoryURL = "https://github.com/pointfreeco/swift-snapshot-testing";
@@ -2991,11 +2976,6 @@
29912976
package = AA36CDB928A6622A00180A33 /* XCRemoteSwiftPackageReference "tweetnacl-swiftwrap" */;
29922977
productName = TweetNacl;
29932978
};
2994-
AA36CDDD28A6878000180A33 /* AlamofireImage */ = {
2995-
isa = XCSwiftPackageProductDependency;
2996-
package = AA36CDDC28A6878000180A33 /* XCRemoteSwiftPackageReference "AlamofireImage" */;
2997-
productName = AlamofireImage;
2998-
};
29992979
AABF826C28AD185E00CDAC64 /* TweetNacl */ = {
30002980
isa = XCSwiftPackageProductDependency;
30012981
package = AA36CDB928A6622A00180A33 /* XCRemoteSwiftPackageReference "tweetnacl-swiftwrap" */;
@@ -3006,11 +2986,6 @@
30062986
package = AA36CDC228A6711300180A33 /* XCRemoteSwiftPackageReference "Popover" */;
30072987
productName = Popover;
30082988
};
3009-
AABF827028AD188700CDAC64 /* AlamofireImage */ = {
3010-
isa = XCSwiftPackageProductDependency;
3011-
package = AA36CDDC28A6878000180A33 /* XCRemoteSwiftPackageReference "AlamofireImage" */;
3012-
productName = AlamofireImage;
3013-
};
30142989
AABF827228AE2FF500CDAC64 /* GradientProgressBar */ = {
30152990
isa = XCSwiftPackageProductDependency;
30162991
package = AA36CDCA28A673C900180A33 /* XCRemoteSwiftPackageReference "GradientProgressBar" */;

PIA VPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

PIA VPN/Core/Extensions/Server+UI.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import Foundation
2424
import PIALibrary
25-
import Alamofire
2625
import UIKit
2726

2827
extension Server: CustomStringConvertible {
@@ -104,4 +103,20 @@ extension UIImage {
104103
UIGraphicsEndImageContext()
105104
return newImage
106105
}
106+
107+
func aspectScaled(toFit size: CGSize) -> UIImage? {
108+
let aspectWidth = size.width / self.size.width
109+
let aspectHeight = size.height / self.size.height
110+
let aspectRatio = min(aspectWidth, aspectHeight)
111+
112+
let scaledSize = CGSize(
113+
width: self.size.width * aspectRatio,
114+
height: self.size.height * aspectRatio
115+
)
116+
117+
let renderer = UIGraphicsImageRenderer(size: scaledSize)
118+
return renderer.image { _ in
119+
self.draw(in: CGRect(origin: .zero, size: scaledSize))
120+
}
121+
}
107122
}

PIA VPN/Resources/Components.plist

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@
5555
<key>LicenseURL</key>
5656
<string>https://raw.githubusercontent.com/hkellaway/Gloss/develop/LICENSE</string>
5757
</dict>
58-
<dict>
59-
<key>Name</key>
60-
<string>Alamofire</string>
61-
<key>Copyright</key>
62-
<string>Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)</string>
63-
<key>LicenseURL</key>
64-
<string>https://raw.githubusercontent.com/Alamofire/Alamofire/master/LICENSE</string>
65-
</dict>
6658
<dict>
6759
<key>Name</key>
6860
<string>ReachabilitySwift</string>
@@ -159,14 +151,14 @@
159151
<key>LicenseURL</key>
160152
<string>https://raw.githubusercontent.com/nanopb/nanopb/master/LICENSE.txt</string>
161153
</dict>
162-
<dict>
163-
<key>Name</key>
164-
<string>Popover</string>
165-
<key>Copyright</key>
166-
<string>© 2020 corin8823</string>
167-
<key>LicenseURL</key>
168-
<string>https://raw.githubusercontent.com/corin8823/Popover/master/LICENSE</string>
169-
</dict>
154+
<dict>
155+
<key>Name</key>
156+
<string>Popover</string>
157+
<key>Copyright</key>
158+
<string>© 2020 corin8823</string>
159+
<key>LicenseURL</key>
160+
<string>https://raw.githubusercontent.com/corin8823/Popover/master/LICENSE</string>
161+
</dict>
170162
</array>
171163
</dict>
172164
</plist>

PIA VPN/UI/Settings/SettingsViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import SafariServices
2828
import SwiftyBeaver
2929
import PIAWireguard
3030
import WidgetKit
31-
import AlamofireImage
3231

3332
private let log = SwiftyBeaver.self
3433

@@ -578,7 +577,7 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
578577

579578
cell.textLabel?.text = section.localizedTitleMessage()
580579
cell.detailTextLabel?.text = ""
581-
cell.imageView?.image = section.imageForSection().af_imageAspectScaled(toFit: CGSize(width: 25, height: 25))
580+
cell.imageView?.image = section.imageForSection().aspectScaled(toFit: CGSize(width: 25, height: 25))
582581

583582
switch section {
584583
case .automation:

0 commit comments

Comments
 (0)