Skip to content

Commit 56cbd2d

Browse files
authored
[Auth] Fix Firebase Auth build on visionOS (#11488)
Fixed Firebase Auth SDK build issues for visionOS, along with corresponding unit test changes.
1 parent dc754ba commit 56cbd2d

17 files changed

+60
-33
lines changed

FirebaseAuth/Sources/Auth/FIRAuth.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ - (instancetype)initWithApp:(FIRApp *)app {
469469
appCheck:FIR_COMPONENT(FIRAppCheckInterop, app.container)];
470470
if (self) {
471471
_app = app;
472-
#if TARGET_OS_IOS
472+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
473473
_authURLPresenter = [[FIRAuthURLPresenter alloc] init];
474-
#endif
474+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
475475
}
476476
return self;
477477
}
@@ -648,7 +648,7 @@ - (nullable FIRUser *)currentUser {
648648
- (void)signInWithProvider:(id<FIRFederatedAuthProvider>)provider
649649
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
650650
completion:(nullable FIRAuthDataResultCallback)completion {
651-
#if TARGET_OS_IOS
651+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
652652
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
653653
FIRAuthDataResultCallback decoratedCallback =
654654
[self signInFlowAuthDataResultCallbackByDecoratingCallback:completion];
@@ -665,7 +665,7 @@ - (void)signInWithProvider:(id<FIRFederatedAuthProvider>)provider
665665
callback:decoratedCallback];
666666
}];
667667
});
668-
#endif // TARGET_OS_IOS
668+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
669669
}
670670

671671
- (void)fetchSignInMethodsForEmail:(nonnull NSString *)email
@@ -1638,9 +1638,11 @@ - (BOOL)canHandleNotification:(NSDictionary *)userInfo {
16381638

16391639
- (BOOL)canHandleURL:(NSURL *)URL {
16401640
__block BOOL result = NO;
1641+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
16411642
dispatch_sync(FIRAuthGlobalWorkQueue(), ^{
16421643
result = [self->_authURLPresenter canHandleURL:URL];
16431644
});
1645+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
16441646
return result;
16451647
}
16461648

FirebaseAuth/Sources/AuthProvider/OAuth/FIROAuthProvider.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ + (instancetype)providerWithProviderID:(NSString *)providerID auth:(FIRAuth *)au
149149
return [[self alloc] initWithProviderID:providerID auth:auth];
150150
}
151151

152-
#if TARGET_OS_IOS
152+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
153153
- (void)getCredentialWithUIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
154154
completion:(nullable FIRAuthCredentialCallback)completion {
155155
if (![FIRAuthWebUtils isCallbackSchemeRegisteredForCustomURLScheme:self->_callbackScheme]) {
@@ -216,7 +216,7 @@ - (void)getCredentialWithUIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
216216
}];
217217
});
218218
}
219-
#endif // TARGET_OS_IOS
219+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
220220

221221
#pragma mark - Internal Methods
222222

FirebaseAuth/Sources/AuthProvider/Phone/FIRPhoneAuthProvider.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
#import <TargetConditionals.h>
18-
#if TARGET_OS_IOS
18+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
1919

2020
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthSettings.h"
2121
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRMultiFactorResolver.h"
@@ -789,4 +789,4 @@ - (void)reCAPTCHAURLWithEventID:(NSString *)eventID completion:(FIRReCAPTCHAURLC
789789

790790
NS_ASSUME_NONNULL_END
791791

792-
#endif
792+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)

FirebaseAuth/Sources/Public/FirebaseAuth/FIRFederatedAuthProvider.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ typedef void (^FIRAuthCredentialCallback)(FIRAuthCredential *_Nullable credentia
4747
- (void)getCredentialWithUIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
4848
completion:(nullable void (^)(FIRAuthCredential *_Nullable credential,
4949
NSError *_Nullable error))completion
50-
API_UNAVAILABLE(macos, tvos, watchos);
50+
API_UNAVAILABLE(macos,
51+
tvos,
52+
watchos
53+
#if defined(TARGET_OS_XR)
54+
,
55+
xros
56+
#endif // defined(TARGET_OS_XR)
57+
);
5158

5259
@end
5360

FirebaseAuth/Sources/SystemService/FIRAuthAPNSTokenManager.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ - (void)getTokenWithCallback:(FIRAuthAPNSTokenCallback)callback {
7979
} else {
8080
#pragma clang diagnostic push
8181
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
82-
#if TARGET_OS_IOS
82+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
8383
[self->_application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert];
84-
#endif // TARGET_OS_IOS
84+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
8585
#pragma clang diagnostic pop
8686
}
8787
});

FirebaseAuth/Sources/SystemService/FIRAuthNotificationManager.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ - (void)checkNotificationForwardingWithCallback:(FIRAuthNotificationForwardingCa
115115
didReceiveRemoteNotification:proberNotification
116116
fetchCompletionHandler:^(UIBackgroundFetchResult result){
117117
}];
118-
#if !TARGET_OS_TV
118+
#if !TARGET_OS_TV && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
119119
} else if ([self->_application.delegate
120120
respondsToSelector:@selector(application:didReceiveRemoteNotification:)]) {
121121
// iOS 10 deprecation
@@ -124,7 +124,7 @@ - (void)checkNotificationForwardingWithCallback:(FIRAuthNotificationForwardingCa
124124
[self->_application.delegate application:self->_application
125125
didReceiveRemoteNotification:proberNotification];
126126
#pragma clang diagnostic pop
127-
#endif
127+
#endif // !TARGET_OS_TV && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
128128
} else {
129129
FIRLogWarning(kFIRLoggerAuth, @"I-AUT000015",
130130
@"The UIApplicationDelegate must handle remote notification for phone number "

FirebaseAuth/Sources/User/FIRUser.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ - (void)reauthenticateWithCredential:(FIRAuthCredential *)credential
850850
- (void)reauthenticateWithProvider:(id<FIRFederatedAuthProvider>)provider
851851
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
852852
completion:(nullable FIRAuthDataResultCallback)completion {
853-
#if TARGET_OS_IOS
853+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
854854
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
855855
[provider getCredentialWithUIDelegate:UIDelegate
856856
completion:^(FIRAuthCredential *_Nullable credential,
@@ -863,7 +863,7 @@ - (void)reauthenticateWithProvider:(id<FIRFederatedAuthProvider>)provider
863863
completion:completion];
864864
}];
865865
});
866-
#endif // TARGET_OS_IOS
866+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
867867
}
868868

869869
- (nullable NSString *)refreshToken {
@@ -1339,7 +1339,7 @@ - (void)linkWithCredential:(FIRAuthCredential *)credential
13391339
- (void)linkWithProvider:(id<FIRFederatedAuthProvider>)provider
13401340
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
13411341
completion:(nullable FIRAuthDataResultCallback)completion {
1342-
#if TARGET_OS_IOS
1342+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
13431343
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
13441344
[provider getCredentialWithUIDelegate:UIDelegate
13451345
completion:^(FIRAuthCredential *_Nullable credential,
@@ -1351,7 +1351,7 @@ - (void)linkWithProvider:(id<FIRFederatedAuthProvider>)provider
13511351
[self linkWithCredential:credential completion:completion];
13521352
}];
13531353
});
1354-
#endif // TARGET_OS_IOS
1354+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
13551355
}
13561356

13571357
- (void)unlinkFromProvider:(NSString *)provider

FirebaseAuth/Sources/Utilities/FIRAuthDefaultUIDelegate.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ - (void)dismissViewControllerAnimated:(BOOL)flag completion:(nullable void (^)(v
9191
}
9292
}
9393
} else {
94+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
9495
UIApplication *application = [applicationClass sharedApplication];
9596
// iOS 13 deprecation
9697
#pragma clang diagnostic push
9798
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
9899
topViewController = application.keyWindow.rootViewController;
99100
#pragma clang diagnostic pop
101+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
100102
}
101103
#else
102104
UIApplication *application = [applicationClass sharedApplication];

FirebaseAuth/Sources/Utilities/FIRAuthURLPresenter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
#import <TargetConditionals.h>
18-
#if TARGET_OS_IOS
18+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
1919

2020
#import <Foundation/Foundation.h>
2121

@@ -66,4 +66,4 @@ typedef BOOL (^FIRAuthURLCallbackMatcher)(NSURL *_Nullable callbackURL);
6666

6767
NS_ASSUME_NONNULL_END
6868

69-
#endif
69+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)

FirebaseAuth/Sources/Utilities/FIRAuthURLPresenter.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
#import <TargetConditionals.h>
18-
#if TARGET_OS_IOS
18+
#if TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)
1919

2020
#import <SafariServices/SafariServices.h>
2121
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthUIDelegate.h"
@@ -205,4 +205,4 @@ - (void)finishPresentationWithURL:(nullable NSURL *)URL error:(nullable NSError
205205

206206
NS_ASSUME_NONNULL_END
207207

208-
#endif
208+
#endif // TARGET_OS_IOS && (!defined(TARGET_OS_XR) || !TARGET_OS_XR)

0 commit comments

Comments
 (0)