Skip to content

[Infra] Remove outdated availability and Swift version guards #1711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions abtesting/Shared/AppConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class AppConfig: ObservableObject {
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
@available(iOS 15, tvOS 15, macOS 12, watchOS 8, *)
func updateFromRemoteConfigAsync() async {
let remoteConfig = RemoteConfig.remoteConfig()
let oldValue = remoteConfig["color_scheme"].stringValue ?? "nil"
Expand Down
18 changes: 2 additions & 16 deletions abtesting/Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,11 @@ struct FirebaseList: View {
]
var body: some View {
VStack {
#if compiler(>=5.5) && canImport(_Concurrency)
if #available(iOS 15, tvOS 15, macOS 12, watchOS 8, *) {
BasicList(data: data)
.preferredColorScheme(appConfig.colorScheme)
.foregroundColor(appConfig.colorScheme == .dark ? .orange : .primary)
.task { await appConfig.updateFromRemoteConfigAsync() }
.refreshable { await appConfig.updateFromRemoteConfigAsync() }
} else {
BasicList(data: data)
.preferredColorScheme(appConfig.colorScheme)
.foregroundColor(appConfig.colorScheme == .dark ? .orange : .primary)
.onAppear { appConfig.updateFromRemoteConfig() }
}
#else
BasicList(data: data)
.preferredColorScheme(appConfig.colorScheme)
.foregroundColor(appConfig.colorScheme == .dark ? .orange : .primary)
.onAppear { appConfig.updateFromRemoteConfig() }
#endif
.task { await appConfig.updateFromRemoteConfigAsync() }
.refreshable { await appConfig.updateFromRemoteConfigAsync() }
Button("Refresh") { appConfig.updateFromRemoteConfig() }
Spacer()
}
Expand Down
8 changes: 3 additions & 5 deletions abtesting/Shared/UITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ class UITests: XCTestCase {
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
10 changes: 4 additions & 6 deletions analytics/AnalyticsExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
didFinishLaunchingWithOptions launchOptions: [UIApplication
.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
if #available(iOS 14, *) {
SKPaymentQueue.default().add(FirebaseApp.app()!)
print("\(SKPaymentQueue.default().transactionObservers as [AnyObject])")
SKPaymentQueue.default().add(FirebaseApp.app()!)
print("\(SKPaymentQueue.default().transactionObservers as [AnyObject])")

(SKPaymentQueue.default().transactionObservers as [AnyObject]).forEach {
print($0)
}
(SKPaymentQueue.default().transactionObservers as [AnyObject]).forEach {
print($0)
}
print("done")
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ class AppDistributionExampleUITests: XCTestCase {
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) {
XCUIApplication().launch()
}
// This measures how long it takes to launch your application.
measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) {
XCUIApplication().launch()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

// [START new_delegate]
@available(iOS 9.0, *)
func application(_ application: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any])
-> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,8 @@ class MainViewController: UITableViewController {
}
}
case .authApple:
if #available(iOS 13, *) {
action = UIAlertAction(title: "Apple", style: .default) { UIAlertAction in
self.startSignInWithAppleFlow()
}
} else {
continue
action = UIAlertAction(title: "Apple", style: .default) { UIAlertAction in
self.startSignInWithAppleFlow()
}
case .authFacebook:
action = UIAlertAction(title: "Facebook", style: .default) { UIAlertAction in
Expand Down Expand Up @@ -1026,7 +1022,6 @@ class MainViewController: UITableViewController {
// Unhashed nonce.
fileprivate var currentNonce: String?

@available(iOS 13, *)
func startSignInWithAppleFlow() {
let nonce = randomNonceString()
currentNonce = nonce
Expand Down Expand Up @@ -1066,7 +1061,6 @@ class MainViewController: UITableViewController {
// [END random_nonce]

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

@available(iOS 13.0, *)
extension MainViewController: ASAuthorizationControllerDelegate {
func authorizationController(controller: ASAuthorizationController,
didCompleteWithAuthorization authorization: ASAuthorization) {
Expand Down Expand Up @@ -1113,7 +1106,6 @@ extension MainViewController: ASAuthorizationControllerDelegate {
}
}

@available(iOS 13.0, *)
extension MainViewController: ASAuthorizationControllerPresentationContextProviding {
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
return view.window!
Expand Down
22 changes: 3 additions & 19 deletions crashlytics/Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ struct CrashButtonView: View {
struct ContentView: View {
private var crashlyticsReference = Crashlytics.crashlytics()

#if compiler(>=5.5) && canImport(_Concurrency)
@available(iOS 15, tvOS 15, macOS 12, watchOS 8, *) func checkForUnsentReportsAsync() async {
func checkForUnsentReportsAsync() async {
let reportFound = await crashlyticsReference.checkForUnsentReports()
if reportFound {
crashlyticsReference.sendUnsentReports()
}
}
#endif

func checkForUnsentReports() {
crashlyticsReference.checkForUnsentReports { reportFound in
Expand All @@ -51,24 +49,10 @@ struct ContentView: View {
}

var body: some View {
if #available(iOS 15, tvOS 15, macOS 12, watchOS 8, *) {
#if compiler(>=5.5) && canImport(_Concurrency)
CrashButtonView()
.task {
await self.checkForUnsentReportsAsync()
}
#else
CrashButtonView()
.onAppear {
self.checkForUnsentReports()
}
#endif
} else {
CrashButtonView()
.onAppear {
self.checkForUnsentReports()
.task {
await self.checkForUnsentReportsAsync()
}
}
}
}

Expand Down
8 changes: 3 additions & 5 deletions crashlytics/Shared/UITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ class UITests: XCTestCase {
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,9 @@ struct PostCell: View {
#if os(iOS) || os(macOS)
starButton
.onTapGesture {
if #available(iOS 15, macOS 12, *) {
#if compiler(>=5.5) && canImport(_Concurrency)
Task { await
post.didTapStarButtonAsync()
}
#else
post.didTapStarButton()
#endif
} else {
post.didTapStarButton()
}
Task { await
post.didTapStarButtonAsync()
}
}
#elseif os(tvOS)
starButton
Expand Down
10 changes: 2 additions & 8 deletions firestore/FirestoreExample/UINavigationBar+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ extension UINavigationBar {
static let firebaseTitleTextAttributes =
[NSAttributedString.Key.foregroundColor: UIColor.white]

@available(iOS 13.0, *)
var firebaseNavigationBarAppearance: UINavigationBarAppearance {
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
Expand All @@ -29,23 +28,18 @@ extension UINavigationBar {
return navBarAppearance
}

@available(iOS 13.0, *)
func applyAppearance(_ appearance: UINavigationBarAppearance) {
standardAppearance = appearance
compactAppearance = appearance
scrollEdgeAppearance = appearance
if #available(iOS 15.0, *) {
compactScrollEdgeAppearance = appearance
}
compactScrollEdgeAppearance = appearance
}

func applyFirebaseAppearance() {
barTintColor = UINavigationBar.firebaseBlue
isTranslucent = false
titleTextAttributes = UINavigationBar.firebaseTitleTextAttributes

if #available(iOS 13.0, *) {
applyAppearance(firebaseNavigationBarAppearance)
}
applyAppearance(firebaseNavigationBarAppearance)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

@available(iOS 9.0, *)
func application(_ app: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
guard let sourceApplication =
Expand All @@ -51,7 +50,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return handleOpenUrl(url, sourceApplication: sourceApplication)
}

@available(iOS 8.0, *)
func application(_ application: UIApplication, open url: URL, sourceApplication: String?,
annotation: Any) -> Bool {
return handleOpenUrl(url, sourceApplication: sourceApplication)
Expand Down
Loading
Loading