Skip to content

Commit ed9c64f

Browse files
authored
chore Removing unneeded availability checks (#1469)
<!-- πŸŽ‰ Thank you for submitting a pull request! πŸŽ‰ --> ## Summary - removes all #available below iOS 13
2 parents 420147f + f3d35b1 commit ed9c64f

File tree

9 files changed

+34
-77
lines changed

9 files changed

+34
-77
lines changed

β€ŽAdyen.xcodeproj/project.pbxproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@
150150
81825CB92AC59C3300F91912 /* UIView+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CB72AC59C3300F91912 /* UIView+Search.swift */; };
151151
81825CBB2AC59C4000F91912 /* UIViewController+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CBA2AC59C4000F91912 /* UIViewController+Search.swift */; };
152152
81825CBC2AC59C4000F91912 /* UIViewController+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CBA2AC59C4000F91912 /* UIViewController+Search.swift */; };
153-
81825CBE2AC59C4B00F91912 /* XCTestCase+Available.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CBD2AC59C4B00F91912 /* XCTestCase+Available.swift */; };
154-
81825CBF2AC59C4B00F91912 /* XCTestCase+Available.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CBD2AC59C4B00F91912 /* XCTestCase+Available.swift */; };
155153
81825CC12AC59C6400F91912 /* XCTestCase+RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CC02AC59C6400F91912 /* XCTestCase+RootViewController.swift */; };
156154
81825CC22AC59C6400F91912 /* XCTestCase+RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CC02AC59C6400F91912 /* XCTestCase+RootViewController.swift */; };
157155
81825CC42AC59C6C00F91912 /* XCTestCase+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CC32AC59C6C00F91912 /* XCTestCase+Wait.swift */; };
@@ -1366,7 +1364,6 @@
13661364
814276612A7145F50081E896 /* AddressInputFormViewController+ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AddressInputFormViewController+ViewModel.swift"; sourceTree = "<group>"; };
13671365
81825CB72AC59C3300F91912 /* UIView+Search.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Search.swift"; sourceTree = "<group>"; };
13681366
81825CBA2AC59C4000F91912 /* UIViewController+Search.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Search.swift"; sourceTree = "<group>"; };
1369-
81825CBD2AC59C4B00F91912 /* XCTestCase+Available.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTestCase+Available.swift"; sourceTree = "<group>"; };
13701367
81825CC02AC59C6400F91912 /* XCTestCase+RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTestCase+RootViewController.swift"; sourceTree = "<group>"; };
13711368
81825CC32AC59C6C00F91912 /* XCTestCase+Wait.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTestCase+Wait.swift"; sourceTree = "<group>"; };
13721369
81896E842A4DB5F300C532CA /* SearchViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewControllerTests.swift; sourceTree = "<group>"; };
@@ -2905,7 +2902,6 @@
29052902
children = (
29062903
81825CB72AC59C3300F91912 /* UIView+Search.swift */,
29072904
81825CBA2AC59C4000F91912 /* UIViewController+Search.swift */,
2908-
81825CBD2AC59C4B00F91912 /* XCTestCase+Available.swift */,
29092905
81825CC32AC59C6C00F91912 /* XCTestCase+Wait.swift */,
29102906
F96AE51A26038602009F82BD /* XCTestCaseExtension.swift */,
29112907
81825CC02AC59C6400F91912 /* XCTestCase+RootViewController.swift */,
@@ -6726,7 +6722,6 @@
67266722
F924C072246BEEF0006DDAB8 /* CardDetailsTests.swift in Sources */,
67276723
F9FE39E32679E09200F02A9B /* LoadingViewTests.swift in Sources */,
67286724
F96A25472372C39F007DBF0B /* ApplePayDetailsTest.swift in Sources */,
6729-
81825CBE2AC59C4B00F91912 /* XCTestCase+Available.swift in Sources */,
67306725
A07B2CF226A5D4FE0008185C /* BrazilSocialSecurityNumberFormatterTests.swift in Sources */,
67316726
A04E60DB27F30D900051C72C /* SessionDelegateMock.swift in Sources */,
67326727
F9AC61C424375F510062A00D /* PresentingViewControllerMock.swift in Sources */,
@@ -7223,7 +7218,6 @@
72237218
00220955299B8B1C00B2BACD /* BLIKComponentUITests.swift in Sources */,
72247219
81825CC22AC59C6400F91912 /* XCTestCase+RootViewController.swift in Sources */,
72257220
F9CCA3D7296ECDB200AD643D /* XCTestCase+Coder.swift in Sources */,
7226-
81825CBF2AC59C4B00F91912 /* XCTestCase+Available.swift in Sources */,
72277221
F9CCA3C5296ECB9900AD643D /* ListViewControllerUITests.swift in Sources */,
72287222
F9CCA3D3296ECD0700AD643D /* PostalAddressMocks.swift in Sources */,
72297223
);

β€ŽAdyen/UI/View Controllers/SecuredViewController.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,10 @@ public final class SecuredViewController<ChildViewController: UIViewController>:
8282
private var blurEffectView: UIVisualEffectView
8383

8484
private lazy var blurEffect: UIBlurEffect = {
85-
if #available(iOS 12.0, *) {
86-
switch traitCollection.userInterfaceStyle {
87-
case .dark:
88-
return UIBlurEffect(style: .dark)
89-
case .light, .unspecified:
90-
return UIBlurEffect(style: .light)
91-
@unknown default:
92-
return UIBlurEffect(style: .light)
93-
}
94-
} else {
85+
switch traitCollection.userInterfaceStyle {
86+
case .dark:
87+
return UIBlurEffect(style: .dark)
88+
default:
9589
return UIBlurEffect(style: .light)
9690
}
9791
}()

β€ŽAdyenComponents/Apple Pay/ApplePayConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ extension PKPaymentNetwork {
177177

178178
internal var txVariantName: String {
179179
if self == .masterCard { return "mc" }
180-
if #available(iOS 11.2, *), self == .cartesBancaires { return "cartebancaire" }
180+
if self == .cartesBancaires { return "cartebancaire" }
181181
return self.rawValue.lowercased()
182182
}
183183

β€ŽAdyenDropIn/Views/PreApplePayView.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ internal final class PreApplePayView: UIView, Localizable {
2626

2727
/// Creates PKPaymentButtonStyle based on Dark or Light Mode.
2828
private var paymentButtonStyleAuto: PKPaymentButtonStyle {
29-
let buttonStyle: PKPaymentButtonStyle
3029
if #available(iOS 14.0, *) {
31-
buttonStyle = .automatic
32-
} else if #available(iOS 12.0, *), traitCollection.userInterfaceStyle == .dark {
33-
buttonStyle = .white
34-
} else {
35-
buttonStyle = .black
30+
return .automatic
31+
}
32+
33+
switch traitCollection.userInterfaceStyle {
34+
case .dark:
35+
return .white
36+
default:
37+
return .black
3638
}
37-
return buttonStyle
3839
}
3940

4041
internal init(model: Model) {
@@ -66,9 +67,7 @@ internal final class PreApplePayView: UIView, Localizable {
6667
])
6768
payButton.accessibilityIdentifier = ViewIdentifierBuilder.build(scopeInstance: self, postfix: "applePayButton")
6869

69-
if #available(iOS 12.0, *) {
70-
payButton.cornerRadius = model.style.cornerRadius
71-
}
70+
payButton.cornerRadius = model.style.cornerRadius
7271
}
7372

7473
private func addHintLabel() {

β€ŽDemo/UIKit/ComponentsView.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,18 @@ internal final class ComponentsView: UIView {
127127
}
128128

129129
private func setUpApplePayCell(_ cell: UITableViewCell) {
130-
let style: PKPaymentButtonStyle
131-
if #available(iOS 14.0, *) {
132-
style = .automatic
133-
} else if #available(iOS 12.0, *), traitCollection.userInterfaceStyle == .dark {
134-
style = .white
135-
} else {
136-
style = .black
137-
}
130+
let style: PKPaymentButtonStyle = {
131+
if #available(iOS 14.0, *) {
132+
return .automatic
133+
}
134+
135+
switch traitCollection.userInterfaceStyle {
136+
case .dark:
137+
return .white
138+
default:
139+
return .black
140+
}
141+
}()
138142

139143
let contentView = cell.contentView
140144

β€ŽTests/Adyen Tests/Utilities/AmountFormatterTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class AmountFormatterTests: XCTestCase {
7676
XCTAssertEqual(AmountFormatter.formatted(amount: amount, currencyCode: "CVE", localeIdentifier: "ko_KR"), "CVEΒ 123,456")
7777
XCTAssertEqual(AmountFormatter.formatted(amount: amount, currencyCode: "CVE", localeIdentifier: "fr_FR"), "123β€―456Β CVE")
7878

79-
if Available.iOS17 {
79+
if #available(iOS 17.0, *) {
8080
XCTAssertEqual(AmountFormatter.formatted(amount: amount, currencyCode: "ISK", localeIdentifier: "is_IS"), "1.234,56Β kr.")
8181
} else {
8282
XCTAssertEqual(AmountFormatter.formatted(amount: amount, currencyCode: "ISK", localeIdentifier: "is_IS"), "1.234,56Β ISK")

β€ŽTests/Card Tests/3DS2 Component/ThreeDS2PlusDACoreActionHandlerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import XCTest
4141

4242
override func setUpWithError() throws {
4343
guard #available(iOS 14.0, *) else {
44-
// XCTestCase does not respect @available so we have skip all tests here
44+
// XCTestCase does not respect @available so we have to skip the test like this
4545
throw XCTSkip("Unsupported iOS version")
4646
}
4747

β€ŽTests/Components Tests/Apple Pay/ApplePayComponentTests.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ class ApplePayComponentTest: XCTestCase {
154154
waitForExpectations(timeout: 4)
155155
}
156156

157-
@available(iOS 15.0, *)
158-
func testApplePayCoupon() {
159-
guard Available.iOS15 else { return }
157+
func testApplePayCoupon() throws {
158+
guard #available(iOS 15.0, *) else {
159+
// XCTestCase does not respect @available so we have to skip the test like this
160+
throw XCTSkip("Unsupported iOS version")
161+
}
160162

161163
sut.applePayDelegate = mockApplePayDelegate
162164
(mockApplePayDelegate as! ApplePayDelegateMockiOS15).onCouponChange = { coupon, payment in
@@ -298,7 +300,7 @@ class ApplePayComponentTest: XCTestCase {
298300

299301
func testNewInitSuccess() throws {
300302
guard #available(iOS 16.0, *) else {
301-
// XCTestCase does not respect @available so we have skip all tests here
303+
// XCTestCase does not respect @available so we have to skip the test like this
302304
throw XCTSkip("Unsupported iOS version")
303305
}
304306

β€ŽTests/Helpers/XCTestCase+Available.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
Β (0)