Skip to content
Draft
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
15 changes: 5 additions & 10 deletions FirebaseAnalytics/Tests/SwiftUnit/AnalyticsAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ final class AnalyticsAPITests {
Analytics.setDefaultEventParameters(["default": 100])

Analytics.sessionID { sessionID, error in }
if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
Task {
let _: Int64? = try? await Analytics.sessionID()
}
Task {
let _: Int64? = try? await Analytics.sessionID()
}

@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, *)
@available(watchOS, unavailable)
func logTransactionUsage() {
let transaction: StoreKit.Transaction! = nil
Expand All @@ -53,11 +50,10 @@ final class AnalyticsAPITests {
// MARK: - AppDelegate

Analytics.handleEvents(forBackgroundURLSession: "session_id", completionHandler: {})
if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
Task {
await Analytics.handleEvents(forBackgroundURLSession: "session_id")
}
Task {
await Analytics.handleEvents(forBackgroundURLSession: "session_id")
}

Analytics.handleOpen(URL(string: "https://google.com")!)
Analytics.handleUserActivity(NSUserActivity(activityType: "editing"))

Expand Down Expand Up @@ -198,7 +194,6 @@ final class AnalyticsAPITests {

// MARK: - Analytics + SwiftUI

@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, *)
@available(watchOS, unavailable)
struct MyView: View {
let name: String
Expand Down
44 changes: 19 additions & 25 deletions FirebaseAppDistribution/Sources/FIRAppDistributionUIService.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ - (void)appDistributionRegistrationFlow:(NSURL *)URL
completion(appDistributionError);
}];

if (@available(iOS 13.0, *)) {
authenticationVC.presentationContextProvider = self;
}
authenticationVC.presentationContextProvider = self;

_webAuthenticationVC = authenticationVC;

Expand Down Expand Up @@ -164,30 +162,26 @@ - (void)initializeUIState {
return;
}

if (@available(iOS 13.0, *)) {
UIWindowScene *foregroundedScene = nil;
for (UIWindowScene *connectedScene in [UIApplication sharedApplication].connectedScenes) {
if (connectedScene.activationState == UISceneActivationStateForegroundActive) {
foregroundedScene = connectedScene;
break;
}
UIWindowScene *foregroundedScene = nil;
for (UIWindowScene *connectedScene in [UIApplication sharedApplication].connectedScenes) {
if (connectedScene.activationState == UISceneActivationStateForegroundActive) {
foregroundedScene = connectedScene;
break;
}
}

if (foregroundedScene) {
self.window = [[UIWindow alloc] initWithWindowScene:foregroundedScene];
} else if ([UIApplication sharedApplication].connectedScenes.count == 1) {
// There are situations where a scene isn't considered foreground in viewDidAppear
// and this fixes the issue in single scene apps.
// https://github.com/firebase/firebase-ios-sdk/issues/8096
UIWindowScene *scene =
(UIWindowScene *)[UIApplication sharedApplication].connectedScenes.anyObject;
self.window = [[UIWindow alloc] initWithWindowScene:scene];
} else {
// TODO: Consider using UISceneDidActivateNotification.
FIRFADInfoLog(@"No foreground scene found.");
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
}
if (foregroundedScene) {
self.window = [[UIWindow alloc] initWithWindowScene:foregroundedScene];
} else if ([UIApplication sharedApplication].connectedScenes.count == 1) {
// There are situations where a scene isn't considered foreground in viewDidAppear
// and this fixes the issue in single scene apps.
// https://github.com/firebase/firebase-ios-sdk/issues/8096
UIWindowScene *scene =
(UIWindowScene *)[UIApplication sharedApplication].connectedScenes.anyObject;
self.window = [[UIWindow alloc] initWithWindowScene:scene];
} else {
// TODO: Consider using UISceneDidActivateNotification.
FIRFADInfoLog(@"No foreground scene found.");
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
}
self.window.rootViewController = self.safariHostingViewController;
Expand Down Expand Up @@ -223,7 +217,7 @@ - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
}

- (ASPresentationAnchor)presentationAnchorForWebAuthenticationSession:
(ASWebAuthenticationSession *)session API_AVAILABLE(ios(13.0)) {
(ASWebAuthenticationSession *)session {
return self.safariHostingViewController.view.window;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import XCTest

class AppDistributionAPITests: XCTestCase {
@available(iOS 13.0.0, *)
func asyncAPIs() async throws {
let distro = AppDistribution.appDistribution()

Expand Down
6 changes: 2 additions & 4 deletions FirebaseCore/Extension/FIRHeartbeatLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ NS_SWIFT_SENDABLE

#ifndef FIREBASE_BUILD_CMAKE
/// Returns the header value for the heartbeat logger via the given completion handler..
- (void)asyncHeaderValueWithCompletionHandler:(void (^)(NSString *_Nullable))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0));
- (void)asyncHeaderValueWithCompletionHandler:(void (^)(NSString *_Nullable))completionHandler;

/// Return the header value for the heartbeat logger.
- (NSString *_Nullable)headerValue;
Expand Down Expand Up @@ -91,8 +90,7 @@ NSString *_Nullable FIRHeaderValueFromHeartbeatsPayload(FIRHeartbeatsPayload *he
/// @note This API is thread-safe.
/// @param completionHandler A completion handler to process the flushed payload of heartbeats.
- (void)flushHeartbeatsIntoPayloadWithCompletionHandler:
(void (^)(FIRHeartbeatsPayload *))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0));
(void (^)(FIRHeartbeatsPayload *))completionHandler;
#endif // FIREBASE_BUILD_CMAKE

/// Gets today's corresponding heartbeat code.
Expand Down
6 changes: 2 additions & 4 deletions FirebaseCore/Sources/FIRHeartbeatLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ - (NSString *_Nullable)headerValue {
return FIRHeaderValueFromHeartbeatsPayload([self flushHeartbeatsIntoPayload]);
}

- (void)asyncHeaderValueWithCompletionHandler:(void (^)(NSString *_Nullable))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0)) {
- (void)asyncHeaderValueWithCompletionHandler:(void (^)(NSString *_Nullable))completionHandler {
[self flushHeartbeatsIntoPayloadWithCompletionHandler:^(FIRHeartbeatsPayload *payload) {
completionHandler(FIRHeaderValueFromHeartbeatsPayload(payload));
}];
Expand All @@ -87,8 +86,7 @@ - (FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload {
}

- (void)flushHeartbeatsIntoPayloadWithCompletionHandler:
(void (^)(FIRHeartbeatsPayload *))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0)) {
(void (^)(FIRHeartbeatsPayload *))completionHandler {
[_heartbeatController flushAsyncWithCompletionHandler:^(FIRHeartbeatsPayload *payload) {
completionHandler(payload);
}];
Expand Down
8 changes: 3 additions & 5 deletions FirebaseCore/Tests/SwiftUnit/CoreAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ final class CoreAPITests {
// ...
}

if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
await app.delete()
}
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
await app.delete()
}
}

Expand Down
6 changes: 1 addition & 5 deletions FirebaseCore/Tests/Unit/FIRAppTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -865,11 +865,7 @@ - (NSNotificationName)appDidBecomeActiveNotificationName {
return NSApplicationDidBecomeActiveNotification;
#elif TARGET_OS_WATCH
// See comment in `- [FIRApp subscribeForAppDidBecomeActiveNotifications]`.
if (@available(watchOS 7.0, *)) {
return WKApplicationDidBecomeActiveNotification;
} else {
return kFIRAppReadyToConfigureSDKNotification;
}
return WKApplicationDidBecomeActiveNotification;
#endif
}

Expand Down
6 changes: 2 additions & 4 deletions FirebaseCore/Tests/Unit/FIRHeartbeatLoggerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ - (void)testFlushing_UsingV2API_WhenHeartbeatsAreStored_ReturnsNonEmptyPayload {
}];
}

- (void)testFlushingAsync_UsingV2API_WhenHeartbeatsAreStored_ReturnsNonEmptyPayload API_AVAILABLE(
ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0)) {
- (void)testFlushingAsync_UsingV2API_WhenHeartbeatsAreStored_ReturnsNonEmptyPayload {
// Given
FIRHeartbeatLogger *heartbeatLogger = self.heartbeatLogger;
NSString *expectedDate = [[self class] formattedStringForDate:[NSDate date]];
Expand Down Expand Up @@ -158,8 +157,7 @@ - (void)testFlushing_UsingV2API_WhenNoHeartbeatsAreStored_ReturnsEmptyPayload {
[self assertHeartbeatsPayloadIsEmpty:heartbeatsPayload];
}

- (void)testFlushingAsync_UsingV2API_WhenNoHeartbeatsAreStored_ReturnsEmptyPayload API_AVAILABLE(
ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0)) {
- (void)testFlushingAsync_UsingV2API_WhenNoHeartbeatsAreStored_ReturnsEmptyPayload {
// Given
FIRHeartbeatLogger *heartbeatLogger = self.heartbeatLogger;
// When
Expand Down
2 changes: 1 addition & 1 deletion FirebaseFunctions/Sources/Callable+Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public enum StreamResponse<Message: Decodable & Sendable, Result: Decodable & Se
}
}

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@available(macOS 12.0, watchOS 8.0, *)
public extension Callable where Request: Sendable, Response: Sendable {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this remain, minus the iOS and tvOS bits?

Suggested change
public extension Callable where Request: Sendable, Response: Sendable {
@available(macOS 12.0, watchOS 8.0, *)
public extension Callable where Request: Sendable, Response: Sendable {

/// Creates a stream that yields responses from the streaming callable function.
///
Expand Down
2 changes: 1 addition & 1 deletion FirebaseFunctions/Sources/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ enum FunctionsConstants {
}
}

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@available(macOS 12.0, watchOS 8.0, *)
func stream(at url: URL,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this remain, minus the iOS and tvOS bits?

Suggested change
func stream(at url: URL,
@available(macOS 12.0, watchOS 8.0, *)
func stream(at url: URL,

data: SendableWrapper?,
options: HTTPSCallableOptions?,
Expand Down
2 changes: 1 addition & 1 deletion FirebaseFunctions/Sources/HTTPSCallable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public final class HTTPSCallable: NSObject, Sendable {
.callFunction(at: url, withObject: data, options: options, timeout: timeoutInterval)
}

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@available(macOS 12.0, watchOS 8.0, *)
func stream(_ data: SendableWrapper? = nil) -> AsyncThrowingStream<JSONStreamResponse, Error> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this remain, minus the iOS and tvOS bits?

Suggested change
func stream(_ data: SendableWrapper? = nil) -> AsyncThrowingStream<JSONStreamResponse, Error> {
@available(macOS 12.0, watchOS 8.0, *)
func stream(_ data: SendableWrapper? = nil) -> AsyncThrowingStream<JSONStreamResponse, Error> {

functions.stream(at: url, data: data, options: options, timeout: timeoutInterval)
}
Expand Down
2 changes: 1 addition & 1 deletion FirebaseFunctions/Tests/Integration/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ class IntegrationTests: XCTestCase {
/// indicate the callable function does not accept parameters.
private struct EmptyRequest: Encodable, Sendable {}

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@available(macOS 12.0, watchOS 8.0, *)
extension IntegrationTests {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this remain, minus the iOS and tvOS bits?

Suggested change
extension IntegrationTests {
@available(macOS 12.0, watchOS 8.0, *)
extension IntegrationTests {

func testStream_NoArgs() async throws {
// 1. Custom `EmptyRequest` struct is passed as a placeholder generic arg.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,7 @@ - (BOOL)deleteIIDFlagFromPlist:(NSError **)outError {
NSMutableDictionary *plistContent = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
plistContent[kFIRInstallationsIIDCreationTimePlistKey] = nil;

if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
return [plistContent writeToURL:[NSURL fileURLWithPath:path] error:outError];
}

return [plistContent writeToFile:path atomically:YES];
return [plistContent writeToURL:[NSURL fileURLWithPath:path] error:outError];
}

- (BOOL)hasPlistIIDFlag {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,7 @@ - (instancetype)initWithGCMSenderID:(NSString *)GCMSenderID {

NSError *archiverError;
NSKeyedUnarchiver *unarchiver;
if (@available(iOS 11.0, tvOS 11.0, macOS 10.13, *)) {
unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:data error:&archiverError];
} else {
@try {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
#pragma clang diagnostic pop
} @catch (NSException *exception) {
archiverError = [FIRInstallationsErrorUtil keyedArchiverErrorWithException:exception];
}
}
unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:data error:&archiverError];

if (!unarchiver) {
NSError *error = archiverError ?: [FIRInstallationsErrorUtil corruptedIIDTokenData];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ final class InstallationsAPITests {
}
}

if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
try await Installations.installations().installationID()
} catch {
// ...
}
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
try await Installations.installations().installationID()
} catch {
// ...
}
}

Expand All @@ -71,14 +69,12 @@ final class InstallationsAPITests {
}
}

if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
_ = try await Installations.installations().authToken()
} catch {
// ...
}
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
_ = try await Installations.installations().authToken()
} catch {
// ...
}
}

Expand All @@ -91,14 +87,12 @@ final class InstallationsAPITests {
}
}

if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
_ = try await Installations.installations().authTokenForcingRefresh(true)
} catch {
// ...
}
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
_ = try await Installations.installations().authTokenForcingRefresh(true)
} catch {
// ...
}
}

Expand All @@ -109,20 +103,18 @@ final class InstallationsAPITests {
}
}

if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
_ = try await Installations.installations().delete()
} catch let error as NSError
where error.domain == InstallationsErrorDomain && error.code == InstallationsErrorCode
.unknown.rawValue {
// Above is the old way to handle errors.
} catch InstallationsErrorCode.unknown {
// Above is the new way to handle errors.
} catch {
// ...
}
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
_ = try await Installations.installations().delete()
} catch let error as NSError
where error.domain == InstallationsErrorDomain && error.code == InstallationsErrorCode
.unknown.rawValue {
// Above is the old way to handle errors.
} catch InstallationsErrorCode.unknown {
// Above is the new way to handle errors.
} catch {
// ...
}
}

Expand Down
Loading
Loading