Skip to content

Commit 9146fb9

Browse files
Refactor: Remove outdated availability and Swift version guards
Analyzed project deployment targets and removed unnecessary @available, #available, and #if swift guards throughout the codebase. - iOS deployment target standardized at 15.0. - macOS deployment target baseline at 11.0. - tvOS deployment target baseline at 15.0. - watchOS deployment target baseline at 7.0. Removed #if swift(>=X.X) blocks by migrating the code for the newer Swift version into the enclosing scope and deleting the #else blocks.
1 parent 99d6acd commit 9146fb9

File tree

17 files changed

+161
-239
lines changed

17 files changed

+161
-239
lines changed

abtesting/Shared/AppConfig.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class AppConfig: ObservableObject {
5656
}
5757

5858
#if compiler(>=5.5) && canImport(_Concurrency)
59-
@available(iOS 15, tvOS 15, macOS 12, watchOS 8, *)
6059
func updateFromRemoteConfigAsync() async {
6160
let remoteConfig = RemoteConfig.remoteConfig()
6261
let oldValue = remoteConfig["color_scheme"].stringValue ?? "nil"

abtesting/Shared/ContentView.swift

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,11 @@ struct FirebaseList: View {
4040
var body: some View {
4141
VStack {
4242
#if compiler(>=5.5) && canImport(_Concurrency)
43-
if #available(iOS 15, tvOS 15, macOS 12, watchOS 8, *) {
44-
BasicList(data: data)
45-
.preferredColorScheme(appConfig.colorScheme)
46-
.foregroundColor(appConfig.colorScheme == .dark ? .orange : .primary)
47-
.task { await appConfig.updateFromRemoteConfigAsync() }
48-
.refreshable { await appConfig.updateFromRemoteConfigAsync() }
49-
} else {
50-
BasicList(data: data)
51-
.preferredColorScheme(appConfig.colorScheme)
52-
.foregroundColor(appConfig.colorScheme == .dark ? .orange : .primary)
53-
.onAppear { appConfig.updateFromRemoteConfig() }
54-
}
43+
BasicList(data: data)
44+
.preferredColorScheme(appConfig.colorScheme)
45+
.foregroundColor(appConfig.colorScheme == .dark ? .orange : .primary)
46+
.task { await appConfig.updateFromRemoteConfigAsync() }
47+
.refreshable { await appConfig.updateFromRemoteConfigAsync() }
5548
#else
5649
BasicList(data: data)
5750
.preferredColorScheme(appConfig.colorScheme)

abtesting/Shared/UITests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,9 @@ class UITests: XCTestCase {
102102
}
103103

104104
func testLaunchPerformance() throws {
105-
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
106-
// This measures how long it takes to launch your application.
107-
measure(metrics: [XCTApplicationLaunchMetric()]) {
108-
XCUIApplication().launch()
109-
}
105+
// This measures how long it takes to launch your application.
106+
measure(metrics: [XCTApplicationLaunchMetric()]) {
107+
XCUIApplication().launch()
110108
}
111109
}
112110
}

analytics/AnalyticsExample/AppDelegate.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3030
didFinishLaunchingWithOptions launchOptions: [UIApplication
3131
.LaunchOptionsKey: Any]?) -> Bool {
3232
FirebaseApp.configure()
33-
if #available(iOS 14, *) {
34-
SKPaymentQueue.default().add(FirebaseApp.app()!)
35-
print("\(SKPaymentQueue.default().transactionObservers as [AnyObject])")
33+
SKPaymentQueue.default().add(FirebaseApp.app()!)
34+
print("\(SKPaymentQueue.default().transactionObservers as [AnyObject])")
3635

37-
(SKPaymentQueue.default().transactionObservers as [AnyObject]).forEach {
38-
print($0)
39-
}
36+
(SKPaymentQueue.default().transactionObservers as [AnyObject]).forEach {
37+
print($0)
4038
}
4139
print("done")
4240
return true

appdistribution/AppDistributionUITests/AppDistributionExampleUITests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ class AppDistributionExampleUITests: XCTestCase {
3636
}
3737

3838
func testLaunchPerformance() throws {
39-
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) {
40-
// This measures how long it takes to launch your application.
41-
measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) {
42-
XCUIApplication().launch()
43-
}
39+
// This measures how long it takes to launch your application.
40+
measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) {
41+
XCUIApplication().launch()
4442
}
4543
}
4644
}

authentication/LegacyAuthQuickstart/AuthenticationExampleSwift/AppDelegate.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4848
}
4949

5050
// [START new_delegate]
51-
@available(iOS 9.0, *)
5251
func application(_ application: UIApplication, open url: URL,
5352
options: [UIApplication.OpenURLOptionsKey: Any])
5453
-> Bool {

authentication/LegacyAuthQuickstart/AuthenticationExampleSwift/MainViewController.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,8 @@ class MainViewController: UITableViewController {
160160
}
161161
}
162162
case .authApple:
163-
if #available(iOS 13, *) {
164-
action = UIAlertAction(title: "Apple", style: .default) { UIAlertAction in
165-
self.startSignInWithAppleFlow()
166-
}
167-
} else {
168-
continue
163+
action = UIAlertAction(title: "Apple", style: .default) { UIAlertAction in
164+
self.startSignInWithAppleFlow()
169165
}
170166
case .authFacebook:
171167
action = UIAlertAction(title: "Facebook", style: .default) { UIAlertAction in
@@ -1026,7 +1022,6 @@ class MainViewController: UITableViewController {
10261022
// Unhashed nonce.
10271023
fileprivate var currentNonce: String?
10281024

1029-
@available(iOS 13, *)
10301025
func startSignInWithAppleFlow() {
10311026
let nonce = randomNonceString()
10321027
currentNonce = nonce
@@ -1066,7 +1061,6 @@ class MainViewController: UITableViewController {
10661061
// [END random_nonce]
10671062

10681063
// [START sha_256]
1069-
@available(iOS 13, *)
10701064
private func sha256(_ input: String) -> String {
10711065
let inputData = Data(input.utf8)
10721066
let hashedData = SHA256.hash(data: inputData)
@@ -1080,7 +1074,6 @@ class MainViewController: UITableViewController {
10801074
// [END sha_256]
10811075
}
10821076

1083-
@available(iOS 13.0, *)
10841077
extension MainViewController: ASAuthorizationControllerDelegate {
10851078
func authorizationController(controller: ASAuthorizationController,
10861079
didCompleteWithAuthorization authorization: ASAuthorization) {
@@ -1113,7 +1106,6 @@ extension MainViewController: ASAuthorizationControllerDelegate {
11131106
}
11141107
}
11151108

1116-
@available(iOS 13.0, *)
11171109
extension MainViewController: ASAuthorizationControllerPresentationContextProviding {
11181110
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
11191111
return view.window!

crashlytics/Shared/ContentView.swift

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct ContentView: View {
3434
private var crashlyticsReference = Crashlytics.crashlytics()
3535

3636
#if compiler(>=5.5) && canImport(_Concurrency)
37-
@available(iOS 15, tvOS 15, macOS 12, watchOS 8, *) func checkForUnsentReportsAsync() async {
37+
func checkForUnsentReportsAsync() async {
3838
let reportFound = await crashlyticsReference.checkForUnsentReports()
3939
if reportFound {
4040
crashlyticsReference.sendUnsentReports()
@@ -51,24 +51,17 @@ struct ContentView: View {
5151
}
5252

5353
var body: some View {
54-
if #available(iOS 15, tvOS 15, macOS 12, watchOS 8, *) {
55-
#if compiler(>=5.5) && canImport(_Concurrency)
56-
CrashButtonView()
57-
.task {
58-
await self.checkForUnsentReportsAsync()
59-
}
60-
#else
61-
CrashButtonView()
62-
.onAppear {
63-
self.checkForUnsentReports()
64-
}
65-
#endif
66-
} else {
54+
#if compiler(>=5.5) && canImport(_Concurrency)
55+
CrashButtonView()
56+
.task {
57+
await self.checkForUnsentReportsAsync()
58+
}
59+
#else
6760
CrashButtonView()
6861
.onAppear {
6962
self.checkForUnsentReports()
7063
}
71-
}
64+
#endif
7265
}
7366
}
7467

crashlytics/Shared/UITests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ class UITests: XCTestCase {
3636
}
3737

3838
func testLaunchPerformance() throws {
39-
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
40-
// This measures how long it takes to launch your application.
41-
measure(metrics: [XCTApplicationLaunchMetric()]) {
42-
XCUIApplication().launch()
43-
}
39+
// This measures how long it takes to launch your application.
40+
measure(metrics: [XCTApplicationLaunchMetric()]) {
41+
XCUIApplication().launch()
4442
}
4543
}
4644
}

database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostCell.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,13 @@ struct PostCell: View {
3131
#if os(iOS) || os(macOS)
3232
starButton
3333
.onTapGesture {
34-
if #available(iOS 15, macOS 12, *) {
35-
#if compiler(>=5.5) && canImport(_Concurrency)
36-
Task { await
37-
post.didTapStarButtonAsync()
38-
}
39-
#else
40-
post.didTapStarButton()
41-
#endif
42-
} else {
34+
#if compiler(>=5.5) && canImport(_Concurrency)
35+
Task { await
36+
post.didTapStarButtonAsync()
37+
}
38+
#else
4339
post.didTapStarButton()
44-
}
40+
#endif
4541
}
4642
#elseif os(tvOS)
4743
starButton

0 commit comments

Comments
 (0)