Skip to content

Commit 78a12dd

Browse files
chore: Remove availability annotations (#6759)
Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io>
1 parent 43f1295 commit 78a12dd

33 files changed

+27
-227
lines changed

Samples/SentrySampleShared/SentrySampleShared/DSNDisplayViewController.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ class DSNDisplayViewController: UIViewController {
1212
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
1313
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
1414

15-
if #available(iOS 13.0, *) {
16-
view.backgroundColor = .systemFill
17-
} else {
18-
view.backgroundColor = .lightGray.withAlphaComponent(0.5)
19-
}
15+
view.backgroundColor = .systemFill
2016

2117
label.numberOfLines = 0
2218
label.lineBreakMode = .byCharWrapping

Samples/SentrySampleShared/SentrySampleShared/SampleAppDebugMenu.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ public class SampleAppDebugMenu: NSObject {
77
static var displayingMenu = false
88

99
let window = {
10-
if #available(iOS 13.0, *) {
11-
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
12-
return Window(windowScene: scene)
13-
}
10+
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
11+
return Window(windowScene: scene)
1412
}
1513
return Window()
1614
}()
@@ -51,7 +49,6 @@ public class SampleAppDebugMenu: NSObject {
5149

5250
class Window: UIWindow {
5351

54-
@available(iOS 13.0, *)
5552
override init(windowScene: UIWindowScene) {
5653
super.init(windowScene: windowScene)
5754
commonInit()

Samples/SentrySampleShared/SentrySampleShared/SentrySDKWrapper.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ public struct SentrySDKWrapper {
153153
}
154154

155155
#if !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
156-
if #available(iOS 13.0, *) {
157-
options.configureUserFeedback = configureFeedback(config:)
158-
}
156+
options.configureUserFeedback = configureFeedback(config:)
159157
#endif // !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
160158

161159
options.enableLogs = true
@@ -251,7 +249,6 @@ public struct SentrySDKWrapper {
251249

252250
#if !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
253251
// MARK: User feedback configuration
254-
@available(iOS 13.0, *)
255252
extension SentrySDKWrapper {
256253
var layoutOffset: UIOffset { UIOffset(horizontal: 25, vertical: 75) }
257254

Samples/iOS-Swift/iOS-Swift-UITests/LaunchUITests.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,8 @@ class LaunchUITests: BaseUITest {
5555
app.buttons["showSplitViewButton"].tap()
5656

5757
app.navigationBars["iOS_Swift.SecondarySplitView"].buttons["Root ViewController"].waitForExistence("SplitView not loaded.")
58-
59-
// This validation is currently not working on iOS 12 and iOS 10.
60-
if #available(iOS 13.0, *) {
61-
assertApp()
62-
}
58+
59+
assertApp()
6360
}
6461

6562
func testCheckSlowAndFrozenFrames() {
@@ -114,10 +111,6 @@ class LaunchUITests: BaseUITest {
114111
* transaction leads to the ASAN error.
115112
*/
116113
func testUseAfterFreeAfterUIImageNamedEmptyString() throws {
117-
guard #available(iOS 14, *) else {
118-
throw XCTSkip("Only run for iOS 14 or later")
119-
}
120-
121114
let app = XCUIApplication()
122115

123116
// this primes the state required according to the customer report, by setting a UIImageView.image property to a UIImage(named: "")

Samples/iOS-Swift/iOS-Swift/AppDelegate.swift

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2525
SentrySDKWrapper.shared.startSentry()
2626
SampleAppDebugMenu.shared.display()
2727

28-
if #available(iOS 15.0, *) {
29-
metricKit.receiveReports()
30-
}
28+
metricKit.receiveReports()
3129

3230
return true
3331
}
3432

3533
func applicationWillTerminate(_ application: UIApplication) {
36-
if #available(iOS 15.0, *) {
37-
metricKit.pauseReports()
38-
}
34+
metricKit.pauseReports()
3935

4036
randomDistributionTimer?.invalidate()
4137
randomDistributionTimer = nil
4238
}
4339

4440
// Workaround for 'Stored properties cannot be marked potentially unavailable with '@available''
45-
private var _metricKit: Any?
46-
@available(iOS 15.0, *)
47-
fileprivate var metricKit: MetricKitManager {
48-
if _metricKit == nil {
49-
_metricKit = MetricKitManager()
50-
}
51-
52-
// We know the type so it's fine to force cast.
53-
// swiftlint:disable force_cast
54-
return _metricKit as! MetricKitManager
55-
// swiftlint:enable force_cast
56-
}
41+
private var metricKit = MetricKitManager()
5742

5843
/**
5944
* previously tried putting this in an AppDelegate.load override in ObjC, but it wouldn't run until

Samples/iOS-Swift/iOS-Swift/ExtraViewController.swift

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,14 @@ class ExtraViewController: UIViewController {
6060

6161
@IBAction func highEnergyCPU(_ sender: UIButton) {
6262
highlightButton(sender)
63-
if #available(iOS 15.0, *) {
64-
batteryConsumer = BatteryConsumer(qos: .userInitiated)
65-
batteryConsumer?.start()
66-
}
63+
batteryConsumer = BatteryConsumer(qos: .userInitiated)
64+
batteryConsumer?.start()
6765
}
6866

6967
@IBAction func lowEnergyCPU(_ sender: UIButton) {
7068
highlightButton(sender)
71-
if #available(iOS 15.0, *) {
72-
batteryConsumer = BatteryConsumer(qos: .background)
73-
batteryConsumer?.start()
74-
}
69+
batteryConsumer = BatteryConsumer(qos: .background)
70+
batteryConsumer?.start()
7571
}
7672

7773
@IBAction func stopUsingEnergy(_ sender: UIButton) {
@@ -187,7 +183,6 @@ class ExtraViewController: UIViewController {
187183
self.present(safariVC, animated: true)
188184
}
189185

190-
@available(iOS 13.0, *)
191186
@IBAction func openAuthenticationServicesWebView(_ sender: UIButton) {
192187
let url = URL(string: "https://sentry.io/auth/login/")!
193188
let session = ASWebAuthenticationSession(url: url, callbackURLScheme: "sentry-callback") { url, error in
@@ -394,19 +389,11 @@ class ExtraViewController: UIViewController {
394389
}
395390

396391
@IBAction func showFeedbackWidget(_ sender: Any) {
397-
if #available(iOS 13.0, *) {
398-
SentrySDK.feedback.showWidget()
399-
} else {
400-
showToast(in: self, type: .warning, message: "Feedback widget only available in iOS 13 or later.")
401-
}
392+
SentrySDK.feedback.showWidget()
402393
}
403394

404395
@IBAction func hideFeedbackWidget(_ sender: Any) {
405-
if #available(iOS 13.0, *) {
406-
SentrySDK.feedback.hideWidget()
407-
} else {
408-
showToast(in: self, type: .warning, message: "Feedback widget only available in iOS 13 or later.")
409-
}
396+
SentrySDK.feedback.hideWidget()
410397
}
411398

412399
@IBAction func showCameraUIAction(_ sender: Any) {
@@ -425,7 +412,6 @@ class ExtraViewController: UIViewController {
425412
}
426413
}
427414

428-
@available(iOS 13.0, *)
429415
extension ExtraViewController: ASWebAuthenticationPresentationContextProviding {
430416
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
431417
guard let window = view.window else {

Samples/iOS-Swift/iOS-Swift/Tools/EnergyConsumer.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ final class BatteryConsumer {
1313
private let lock = NSLock()
1414
private var running = false
1515

16-
@available(iOS 15.0, *)
1716
func start() {
1817
lock.lock()
1918
defer { lock.unlock() }

Samples/iOS-Swift/iOS-Swift/Tools/MetricKitManager.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Foundation
22
import MetricKit
33
import Sentry
44

5-
@available(iOS 14.0, *)
65
class MetricKitManager: NSObject, MXMetricManagerSubscriber {
76
func receiveReports() {
87
let shared = MXMetricManager.shared

Samples/iOS-Swift/iOS-Swift/Tools/TriggerAppHang.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func triggerFullyBlockingAppHangThreadSleeping() {
2626
}
2727

2828
// Blocks the main thread for 5 seconds while decoding an image in a loop.
29-
@available(iOS 15.0, *)
3029
func triggerFullyBlockingAppHangWithImageDecoding() {
3130

3231
let currentTime = Date()

Samples/iOS-Swift/iOS-Swift/TransactionsViewController.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,7 @@ class TransactionsViewController: UIViewController {
138138
}
139139

140140
@IBAction func appHangFullyBlockingBusyMainThread(_ sender: Any) {
141-
if #available(iOS 15.0, *) {
142-
triggerFullyBlockingAppHangWithImageDecoding()
143-
} else {
144-
triggerFullyBlockingAppHangThreadSleeping()
145-
}
141+
triggerFullyBlockingAppHangWithImageDecoding()
146142
}
147143

148144
@IBAction func captureTransaction(_ sender: UIButton) {

0 commit comments

Comments
 (0)