Parcourir la source

Fix and normalize TARGET_OS macro references. (#129)

Peter Andrews il y a 3 ans
Parent
commit
47fa87701b

+ 23 - 20
GoogleSignIn/Sources/GIDAuthentication.m

@@ -18,10 +18,10 @@
 
 #import "GoogleSignIn/Sources/GIDSignInPreferences.h"
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 #import "GoogleSignIn/Sources/GIDEMMErrorHandler.h"
 #import "GoogleSignIn/Sources/GIDMDMPasscodeState.h"
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h"
 
@@ -57,7 +57,7 @@ static NSString *const kOldIOSSystemName = @"iPhone OS";
 // New UIDevice system name for iOS.
 static NSString *const kNewIOSSystemName = @"iOS";
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 // The specialized GTMAppAuthFetcherAuthorization delegate that handles potential EMM error
 // responses.
@@ -149,7 +149,7 @@ static NSString *const kNewIOSSystemName = @"iOS";
 
 @end
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 @implementation GIDAuthentication {
   // A queue for pending authentication handlers so we don't fire multiple requests in parallel.
@@ -197,24 +197,24 @@ static NSString *const kNewIOSSystemName = @"iOS";
 
 #pragma mark - Private property accessors
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 - (NSString *)emmSupport {
   return
       _authState.lastAuthorizationResponse.request.additionalParameters[kEMMSupportParameterName];
 }
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #pragma mark - Public methods
 
 - (id<GTMFetcherAuthorizationProtocol>)fetcherAuthorizer {
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   GTMAppAuthFetcherAuthorization *authorization = self.emmSupport ?
       [[GTMAppAuthFetcherAuthorizationWithEMMSupport alloc] initWithAuthState:_authState] :
       [[GTMAppAuthFetcherAuthorization alloc] initWithAuthState:_authState];
-#else // TARGET_OS_OSX or TARGET_OS_MACCATALYST
+#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
   GTMAppAuthFetcherAuthorization *authorization =
       [[GTMAppAuthFetcherAuthorization alloc] initWithAuthState:_authState];
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   authorization.tokenRefreshDelegate = self;
   return authorization;
 }
@@ -237,14 +237,14 @@ static NSString *const kNewIOSSystemName = @"iOS";
   }
   // This is the first handler in the queue, a fetch is needed.
   NSMutableDictionary *additionalParameters = [@{} mutableCopy];
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   [additionalParameters addEntriesFromDictionary:
       [GIDAuthentication updatedEMMParametersWithParameters:
           _authState.lastTokenResponse.request.additionalParameters]];
-#else // TARGET_OS_OSX or TARGET_OS_MACCATALYST
+#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
   [additionalParameters addEntriesFromDictionary:
       _authState.lastTokenResponse.request.additionalParameters];
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   additionalParameters[kSDKVersionLoggingParameter] = GIDVersion();
   additionalParameters[kEnvironmentLoggingParameter] = GIDEnvironment();
 
@@ -269,7 +269,7 @@ static NSString *const kNewIOSSystemName = @"iOS";
         [self->_authState updateWithAuthorizationError:error];
       }
     }
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
     [GIDAuthentication handleTokenFetchEMMError:error completion:^(NSError *_Nullable error) {
       // Process the handler queue to call back.
       NSArray *authenticationHandlerQueue;
@@ -283,7 +283,7 @@ static NSString *const kNewIOSSystemName = @"iOS";
         });
       }
     }];
-#else // TARGET_OS_OSX or TARGET_OS_MACCATALYST
+#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
     NSArray *authenticationHandlerQueue;
     @synchronized(self->_authenticationHandlerQueue) {
       authenticationHandlerQueue = [self->_authenticationHandlerQueue copy];
@@ -294,12 +294,14 @@ static NSString *const kNewIOSSystemName = @"iOS";
         action(error ? nil : self, error);
       });
     }
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   }];
 }
 
 #pragma mark - Private methods
-#if TARGET_OS_IOS
+
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
+
 + (NSDictionary *)parametersWithParameters:(NSDictionary *)parameters
                                 emmSupport:(nullable NSString *)emmSupport
                     isPasscodeInfoRequired:(BOOL)isPasscodeInfoRequired {
@@ -346,18 +348,19 @@ static NSString *const kNewIOSSystemName = @"iOS";
     completion(error);
   }
 }
-#endif
+
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #pragma mark - GTMAppAuthFetcherAuthorizationTokenRefreshDelegate
 
 - (nullable NSDictionary *)additionalRefreshParameters:
     (GTMAppAuthFetcherAuthorization *)authorization {
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   return [GIDAuthentication updatedEMMParametersWithParameters:
       authorization.authState.lastTokenResponse.request.additionalParameters];
-#else // TARGET_OS_MACCATALYST or TARGET_OS_OSX
+#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
   return authorization.authState.lastTokenResponse.request.additionalParameters;
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 }
 
 #pragma mark - NSSecureCoding

+ 4 - 4
GoogleSignIn/Sources/GIDAuthentication_Private.h

@@ -32,14 +32,14 @@ NS_ASSUME_NONNULL_BEGIN
 // A representation of the state of the OAuth session for this instance.
 @property(nonatomic, readonly) OIDAuthState *authState;
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 // A string indicating support for Enterprise Mobility Management.
 @property(nonatomic, readonly) NSString *emmSupport;
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 - (instancetype)initWithAuthState:(OIDAuthState *)authState;
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 // Gets a new set of URL parameters that also contains EMM-related URL parameters if needed.
 + (NSDictionary *)parametersWithParameters:(NSDictionary *)parameters
                                 emmSupport:(nullable NSString *)emmSupport
@@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
 // Handles potential EMM error from token fetch response.
 + (void)handleTokenFetchEMMError:(nullable NSError *)error
                       completion:(void (^)(NSError *_Nullable))completion;
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 @end
 

+ 2 - 2
GoogleSignIn/Sources/GIDEMMErrorHandler.h

@@ -15,7 +15,7 @@
  */
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import <Foundation/Foundation.h>
 
@@ -39,4 +39,4 @@ NS_ASSUME_NONNULL_BEGIN
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 2 - 2
GoogleSignIn/Sources/GIDEMMErrorHandler.m

@@ -13,7 +13,7 @@
 // limitations under the License.
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import "GoogleSignIn/Sources/GIDEMMErrorHandler.h"
 
@@ -336,4 +336,4 @@ typedef enum {
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 2 - 2
GoogleSignIn/Sources/GIDMDMPasscodeCache.h

@@ -15,7 +15,7 @@
  */
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import <Foundation/Foundation.h>
 
@@ -43,4 +43,4 @@ NS_ASSUME_NONNULL_BEGIN
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 2 - 2
GoogleSignIn/Sources/GIDMDMPasscodeCache.m

@@ -13,7 +13,7 @@
 // limitations under the License.
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import "GoogleSignIn/Sources/GIDMDMPasscodeCache.h"
 
@@ -298,4 +298,4 @@ static const int64_t kObtainKeychainInfoWaitTime = 3 * NSEC_PER_SEC;
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 2 - 2
GoogleSignIn/Sources/GIDMDMPasscodeState.h

@@ -15,7 +15,7 @@
  */
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import <Foundation/Foundation.h>
 
@@ -51,4 +51,4 @@ NS_ASSUME_NONNULL_BEGIN
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 2 - 2
GoogleSignIn/Sources/GIDMDMPasscodeState.m

@@ -13,7 +13,7 @@
 // limitations under the License.
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import "GoogleSignIn/Sources/GIDMDMPasscodeState.h"
 
@@ -52,4 +52,4 @@ NS_ASSUME_NONNULL_BEGIN
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 2 - 2
GoogleSignIn/Sources/GIDMDMPasscodeState_Private.h

@@ -15,7 +15,7 @@
  */
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import <Foundation/Foundation.h>
 
@@ -37,4 +37,4 @@ NS_ASSUME_NONNULL_BEGIN
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 17 - 19
GoogleSignIn/Sources/GIDSignIn.m

@@ -28,10 +28,8 @@
 #import "GoogleSignIn/Sources/GIDSignInCallbackSchemes.h"
 #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 #import "GoogleSignIn/Sources/GIDAuthStateMigration.h"
-#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
-#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
 #import "GoogleSignIn/Sources/GIDEMMErrorHandler.h"
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import "GoogleSignIn/Sources/GIDAuthentication_Private.h"
 #import "GoogleSignIn/Sources/GIDGoogleUser_Private.h"
@@ -400,7 +398,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
   [self signInWithOptions:options];
 }
 
-#endif
+#endif // TARGET_OS_OSX
 
 - (void)signOut {
   // Clear the current user if there is one.
@@ -562,11 +560,11 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
                                              [schemes clientIdentifierScheme],
                                              kBrowserCallbackPath]];
   NSString *emmSupport;
-#if TARGET_OS_MACCATALYST || TARGET_OS_OSX
-  emmSupport = nil;
-#elif TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   emmSupport = [[self class] isOperatingSystemAtLeast9] ? kEMMVersion : nil;
-#endif
+#elif TARGET_OS_MACCATALYST || TARGET_OS_OSX
+  emmSupport = nil;
+#endif // TARGET_OS_MACCATALYST || TARGET_OS_OSX
 
   NSMutableDictionary<NSString *, NSString *> *additionalParameters = [@{} mutableCopy];
   additionalParameters[kIncludeGrantedScopesParameter] = @"true";
@@ -580,14 +578,14 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
     additionalParameters[kHostedDomainParameter] = options.configuration.hostedDomain;
   }
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   [additionalParameters addEntriesFromDictionary:
       [GIDAuthentication parametersWithParameters:options.extraParams
                                        emmSupport:emmSupport
                            isPasscodeInfoRequired:NO]];
 #elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
   [additionalParameters addEntriesFromDictionary:options.extraParams];
-#endif
+#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
   additionalParameters[kSDKVersionLoggingParameter] = GIDVersion();
   additionalParameters[kEnvironmentLoggingParameter] = GIDEnvironment();
 
@@ -628,7 +626,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
                                  error:error
                             emmSupport:emmSupport];
   }];
-#endif
+#endif // TARGET_OS_OSX
 
 }
 
@@ -656,7 +654,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
       GIDSignInErrorCode errorCode = kGIDSignInErrorCodeUnknown;
       NSDictionary<NSString *, NSObject *> *params = authorizationResponse.additionalParameters;
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
       if (authFlow.emmSupport) {
         [authFlow wait];
         BOOL isEMMError = [[GIDEMMErrorHandler sharedInstance]
@@ -668,7 +666,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
           errorCode = kGIDSignInErrorCodeEMM;
         }
       }
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
       errorString = (NSString *)params[kOAuth2ErrorKeyName];
       if ([errorString isEqualToString:kOAuth2AccessDenied]) {
         errorCode = kGIDSignInErrorCodeCanceled;
@@ -747,7 +745,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
   if (_currentOptions.configuration.openIDRealm) {
     additionalParameters[kOpenIDRealmParameter] = _currentOptions.configuration.openIDRealm;
   }
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   NSDictionary<NSString *, NSObject *> *params =
       authState.lastAuthorizationResponse.additionalParameters;
   NSString *passcodeInfoRequired = (NSString *)params[kEMMPasscodeInfoRequiredKeyName];
@@ -755,7 +753,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
       [GIDAuthentication parametersWithParameters:@{}
                                        emmSupport:authFlow.emmSupport
                            isPasscodeInfoRequired:passcodeInfoRequired.length > 0]];
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   additionalParameters[kSDKVersionLoggingParameter] = GIDVersion();
   additionalParameters[kEnvironmentLoggingParameter] = GIDEnvironment();
 
@@ -786,7 +784,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
       }
     }
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
     if (authFlow.emmSupport) {
       [GIDAuthentication handleTokenFetchEMMError:error completion:^(NSError *error) {
         authFlow.error = error;
@@ -797,7 +795,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
     }
 #elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
     [authFlow next];
-#endif
+#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
   }];
 }
 
@@ -931,7 +929,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
   if (!_currentOptions.presentingWindow) {
     return NO;
   }
-#endif
+#endif // TARGET_OS_OSX
   if (!_currentAuthorizationFlow) {
     return NO;
   }
@@ -996,7 +994,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
   if (!_currentOptions.presentingViewController) {
 #elif TARGET_OS_OSX
   if (!_currentOptions.presentingWindow) {
-#endif
+#endif // TARGET_OS_OSX
     // NOLINTNEXTLINE(google-objc-avoid-throwing-exception)
     [NSException raise:NSInvalidArgumentException
                 format:@"|presentingViewController| must be set."];

+ 1 - 1
GoogleSignIn/Sources/GIDSignInButton.m

@@ -644,4 +644,4 @@ static UIColor *colorForStyleState(GIDSignInButtonColorScheme style,
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST

+ 2 - 2
GoogleSignIn/Sources/GIDSignInInternalOptions.h

@@ -52,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
 #elif TARGET_OS_OSX
 /// The window to use during the flow.
 @property(nonatomic, readonly, weak, nullable) NSWindow *presentingWindow;
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 /// The callback block to be called at the completion of the flow.
 @property(nonatomic, readonly, nullable) GIDSignInCallback callback;
@@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
                                        callback:(nullable GIDSignInCallback)callback;
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 /// Creates the options to sign in silently.
 + (instancetype)silentOptionsWithCallback:(GIDSignInCallback)callback;

+ 7 - 7
GoogleSignIn/Sources/GIDSignInInternalOptions.m

@@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
                                        callback:(nullable GIDSignInCallback)callback {
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
   
   GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
   if (options) {
@@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
     options->_presentingViewController = presentingViewController;
 #elif TARGET_OS_OSX
     options->_presentingWindow = presentingWindow;
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
     options->_loginHint = loginHint;
     options->_callback = callback;
     options->_scopes = [GIDScopes scopesWithBasicProfile:scopes];
@@ -65,19 +65,19 @@ NS_ASSUME_NONNULL_BEGIN
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
                                        callback:(nullable GIDSignInCallback)callback {
-#else // TARGET_OS_OSX
+#elif TARGET_OS_OSX
 + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
                                presentingWindow:(nullable NSWindow *)presentingWindow
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
                                        callback:(nullable GIDSignInCallback)callback {
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
     GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:configuration
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                                      presentingViewController:presentingViewController
 #elif TARGET_OS_OSX
                                                              presentingWindow:presentingWindow
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                                                     loginHint:loginHint
                                                                 addScopesFlow:addScopesFlow
                                                                        scopes:@[]
@@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
                                                    presentingViewController:nil
 #elif TARGET_OS_OSX
                                                            presentingWindow:nil
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                                                   loginHint:nil
                                                                addScopesFlow:NO
                                                                    callback:callback];
@@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
     options->_presentingViewController = _presentingViewController;
 #elif TARGET_OS_OSX
     options->_presentingWindow = _presentingWindow;
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
     options->_loginHint = _loginHint;
     options->_callback = _callback;
     options->_scopes = _scopes;

+ 1 - 1
GoogleSignIn/Sources/NSBundle+GID3PAdditions.m

@@ -55,7 +55,7 @@ NSString *const GoogleSignInBundleName = @"GoogleSignIn";
       if ([UIFont fontWithName:fontName size:[UIFont systemFontSize]]) {  // size doesn't matter
         continue;
       }
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
       // Load the font data file from the bundle.
       NSString *path = [bundle pathForResource:fontName ofType:@"ttf"];

+ 11 - 8
GoogleSignIn/Tests/Unit/GIDAuthenticationTest.m

@@ -152,23 +152,23 @@ _Static_assert(kChangeTypeEnd == (sizeof(kObservedProperties) / sizeof(*kObserve
   _observedAuths = [[NSMutableArray alloc] init];
   _changesObserved = 0;
   _fakeSystemName = kNewIOSName;
-#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   [GULSwizzler swizzleClass:[UIDevice class]
                    selector:@selector(systemName)
             isClassSelector:NO
                   withBlock:^(id sender) { return self->_fakeSystemName; }];
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 }
 
 - (void)tearDown {
   [GULSwizzler unswizzleClass:[OIDAuthorizationService class]
                      selector:@selector(performTokenRequest:originalAuthorizationResponse:callback:)
               isClassSelector:YES];
-#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   [GULSwizzler unswizzleClass:[UIDevice class]
                      selector:@selector(systemName)
               isClassSelector:NO];
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   for (GIDAuthentication *auth in _observedAuths) {
     for (unsigned int i = 0; i < kNumberOfObservedProperties; ++i) {
       [auth removeObserver:self forKeyPath:kObservedProperties[i]];
@@ -230,7 +230,7 @@ _Static_assert(kChangeTypeEnd == (sizeof(kObservedProperties) / sizeof(*kObserve
 }
 
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
-// Deprecated in iOS 13 and moacOS 10.14
+// Deprecated in iOS 13 and macOS 10.14
 - (void)testLegacyCoding {
   GIDAuthentication *auth = [self auth];
   NSData *data = [NSKeyedArchiver archivedDataWithRootObject:auth];
@@ -238,7 +238,7 @@ _Static_assert(kChangeTypeEnd == (sizeof(kObservedProperties) / sizeof(*kObserve
   XCTAssertEqualObjects(auth, newAuth);
   XCTAssertTrue([GIDAuthentication supportsSecureCoding]);
 }
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 - (void)testFetcherAuthorizer {
   // This is really hard to test without assuming how GTMAppAuthFetcherAuthorization works
@@ -322,7 +322,9 @@ _Static_assert(kChangeTypeEnd == (sizeof(kObservedProperties) / sizeof(*kObserve
 }
 
 #pragma mark - EMM Support
-#if TARGET_OS_IOS
+
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
+
 - (void)testEMMSupport {
   _additionalTokenRequestParameters = @{
     @"emm_support" : @"xyz",
@@ -488,7 +490,8 @@ _Static_assert(kChangeTypeEnd == (sizeof(kObservedProperties) / sizeof(*kObserve
   XCTAssertEqualObjects(auth.authState.lastTokenResponse.request.additionalParameters,
                         expectedParameters);
 }
-#endif
+
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #pragma mark - NSKeyValueObserving
 

+ 1 - 1
GoogleSignIn/Tests/Unit/GIDConfigurationTest.m

@@ -104,6 +104,6 @@
   XCTAssertEqualObjects(configuration, newConfiguration);
   XCTAssertTrue(GIDConfiguration.supportsSecureCoding);
 }
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 @end

+ 2 - 2
GoogleSignIn/Tests/Unit/GIDEMMErrorHandlerTest.m

@@ -13,7 +13,7 @@
 // limitations under the License.
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import <UIKit/UIKit.h>
 #import <XCTest/XCTest.h>
@@ -524,4 +524,4 @@ NS_ASSUME_NONNULL_BEGIN
 
 NS_ASSUME_NONNULL_END
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 1 - 1
GoogleSignIn/Tests/Unit/GIDGoogleUserTest.m

@@ -81,6 +81,6 @@
   XCTAssertEqualObjects(user, newUser);
   XCTAssertTrue(GIDGoogleUser.supportsSecureCoding);
 }
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 @end

+ 2 - 2
GoogleSignIn/Tests/Unit/GIDMDMPasscodeStateTests.m

@@ -14,7 +14,7 @@
 
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import <Foundation/Foundation.h>
 #import <LocalAuthentication/LocalAuthentication.h>
@@ -179,4 +179,4 @@
 
 @end
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 3 - 1
GoogleSignIn/Tests/Unit/GIDProfileDataTest.m

@@ -134,6 +134,7 @@ static NSString *const kFIFEAvatarURL2WithDimension =
 }
 
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
+
 // Deprecated in iOS 13 and macOS 10.14
 - (void)testLegacyCoding {
   GIDProfileData *profileData = [self profileData];
@@ -158,7 +159,8 @@ static NSString *const kFIFEAvatarURL2WithDimension =
   XCTAssertEqualObjects([profileData imageURLWithDimension:kDimension].absoluteString,
                         kFIFEImageURLWithDimension);
 }
-#endif
+
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 - (void)testImageURLWithDimension {
   GIDProfileData *profileData;

+ 1 - 1
GoogleSignIn/Tests/Unit/GIDSignInButtonTest.m

@@ -206,4 +206,4 @@ static NSString * const kAppBundleId = @"FakeBundleID";
 
 @end
 
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST

+ 3 - 3
GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m

@@ -35,7 +35,7 @@
   id presentingViewController = OCMStrictClassMock([UIViewController class]);
 #elif TARGET_OS_OSX
   id presentingWindow = OCMStrictClassMock([NSWindow class]);
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
   NSString *loginHint = @"login_hint";
   GIDSignInCallback callback = ^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {};
   
@@ -45,7 +45,7 @@
                                        presentingViewController:presentingViewController
 #elif TARGET_OS_OSX
                                                presentingWindow:presentingWindow
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                                       loginHint:loginHint
                                                    addScopesFlow:NO
                                                        callback:callback];
@@ -59,7 +59,7 @@
   OCMVerifyAll(presentingViewController);
 #elif TARGET_OS_OSX
   OCMVerifyAll(presentingWindow);
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 }
 
 - (void)testSilentOptions {

+ 2 - 2
GoogleSignIn/Tests/Unit/GIDSignInPreferencesTest.m

@@ -37,10 +37,10 @@
   expectedEnvironment = @"ios-sim";
 #else
   expectedEnvironment = @"ios";
-#endif
+#endif // TARGET_OS_SIMULATOR
 #elif TARGET_OS_OSX
   expectedEnvironment = @"macos";
-#endif
+#endif // TARGET_OS_MACCATALYST
   XCTAssertEqualObjects(environment, expectedEnvironment);
 }
 

+ 26 - 26
GoogleSignIn/Tests/Unit/GIDSignInTest.m

@@ -17,7 +17,7 @@
 #import <UIKit/UIKit.h>
 #elif TARGET_OS_OSX
 #import <AppKit/AppKit.h>
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 #import <SafariServices/SafariServices.h>
 
@@ -31,9 +31,9 @@
 #import "GoogleSignIn/Sources/GIDSignInPreferences.h"
 #import "GoogleSignIn/Sources/GIDAuthentication_Private.h"
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 #import "GoogleSignIn/Sources/GIDEMMErrorHandler.h"
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #import "GoogleSignIn/Tests/Unit/GIDFakeFetcher.h"
 #import "GoogleSignIn/Tests/Unit/GIDFakeFetcherService.h"
@@ -61,7 +61,7 @@
 #import <AppAuth/OIDAuthorizationService+IOS.h>
 #elif TARGET_OS_OSX
 #import <AppAuth/OIDAuthorizationService+Mac.h>
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 #import <GTMAppAuth/GTMAppAuthFetcherAuthorization+Keychain.h>
 #import <GTMAppAuth/GTMAppAuthFetcherAuthorization.h>
@@ -165,7 +165,7 @@ static void *kTestObserverContext = &kTestObserverContext;
 - (UIWindow *)_window;
 
 @end
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 // This class extension exposes GIDSignIn methods to our tests.
 @interface GIDSignIn ()
@@ -202,7 +202,7 @@ static void *kTestObserverContext = &kTestObserverContext;
 #elif TARGET_OS_OSX
   // Mock |NSWindow|.
   id _presentingWindow;
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
   // Mock for |GIDGoogleUser|.
   id _user;
@@ -252,7 +252,7 @@ static void *kTestObserverContext = &kTestObserverContext;
 #elif TARGET_OS_OSX
   // The saved presentingWindow from the authorization request.
   NSWindow *_savedPresentingWindow;
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
   // The saved authorization callback.
   OIDAuthorizationCallback _savedAuthorizationCallback;
@@ -277,9 +277,9 @@ static void *kTestObserverContext = &kTestObserverContext;
 
 - (void)setUp {
   [super setUp];
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   _isEligibleForEMM = [UIDevice currentDevice].systemVersion.integerValue >= 9;
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   _saveAuthorizationReturnValue = YES;
 
   // States
@@ -293,7 +293,7 @@ static void *kTestObserverContext = &kTestObserverContext;
   _presentingViewController = OCMStrictClassMock([UIViewController class]);
 #elif TARGET_OS_OSX
   _presentingWindow = OCMStrictClassMock([NSWindow class]);
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
   _authState = OCMStrictClassMock([OIDAuthState class]);
   OCMStub([_authState alloc]).andReturn(_authState);
   OCMStub([_authState initWithAuthorizationResponse:OCMOCK_ANY]).andReturn(_authState);
@@ -325,7 +325,7 @@ static void *kTestObserverContext = &kTestObserverContext;
            presentingViewController:SAVE_TO_ARG_BLOCK(self->_savedPresentingViewController)
 #elif TARGET_OS_OSX
            presentingWindow:SAVE_TO_ARG_BLOCK(self->_savedPresentingWindow)
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                          callback:COPY_TO_ARG_BLOCK(self->_savedAuthorizationCallback)]);
   OCMStub([self->_oidAuthorizationService
       performTokenRequest:SAVE_TO_ARG_BLOCK(self->_savedTokenRequest)
@@ -375,7 +375,7 @@ static void *kTestObserverContext = &kTestObserverContext;
   OCMVerifyAll(_presentingViewController);
 #elif TARGET_OS_OSX
   OCMVerifyAll(_presentingWindow);
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 
   [_fakeMainBundle stopFaking];
@@ -877,7 +877,7 @@ static void *kTestObserverContext = &kTestObserverContext;
   _presentingViewController = nil;
 #elif TARGET_OS_OSX
   _presentingWindow = nil;
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 
   XCTAssertThrows([_signIn signInWithConfiguration:_configuration
@@ -885,7 +885,7 @@ static void *kTestObserverContext = &kTestObserverContext;
                           presentingViewController:_presentingViewController
 #elif TARGET_OS_OSX
                                   presentingWindow:_presentingWindow
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                               hint:_hint
                                           callback:_callback]);
 }
@@ -902,7 +902,7 @@ static void *kTestObserverContext = &kTestObserverContext;
             presentingViewController:_presentingViewController
 #elif TARGET_OS_OSX
                     presentingWindow:_presentingWindow
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                             callback:nil];
   } @catch (NSException *exception) {
     threw = YES;
@@ -922,7 +922,7 @@ static void *kTestObserverContext = &kTestObserverContext;
             presentingViewController:_presentingViewController
 #elif TARGET_OS_OSX
                     presentingWindow:_presentingWindow
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                 hint:_hint
                             callback:_callback];
   } @catch (NSException *exception) {
@@ -945,7 +945,7 @@ static void *kTestObserverContext = &kTestObserverContext;
 
 #pragma mark - EMM tests
 
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 - (void)testEmmSupportRequestParameters {
   [self OAuthLoginWithAddScopesFlow:NO
@@ -1086,7 +1086,7 @@ static void *kTestObserverContext = &kTestObserverContext;
   XCTAssertNil(_signIn.currentUser, @"should not have current user");
 }
 
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 
 #pragma mark - Helpers
 
@@ -1209,10 +1209,10 @@ static void *kTestObserverContext = &kTestObserverContext;
     [[[_authState expect] andReturn:tokenResponse] lastTokenResponse];
     [[[_authState expect] andReturn:tokenResponse] lastTokenResponse];
     if (oldAccessToken) {
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
       // Corresponds to EMM support 
       [[[_authState expect] andReturn:authResponse] lastAuthorizationResponse];
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
       [[[_authState expect] andReturn:tokenResponse] lastTokenResponse];
       [[[_authState expect] andReturn:tokenResponse] lastTokenResponse];
       [[[_authState expect] andReturn:tokenRequest]
@@ -1235,7 +1235,7 @@ static void *kTestObserverContext = &kTestObserverContext;
         presentingViewController:_presentingViewController
 #elif TARGET_OS_OSX
         presentingWindow:_presentingWindow
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                 callback:callback];
     } else {
       if (useAdditionalScopes) {
@@ -1244,7 +1244,7 @@ static void *kTestObserverContext = &kTestObserverContext;
                 presentingViewController:_presentingViewController
 #elif TARGET_OS_OSX
                         presentingWindow:_presentingWindow
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                     hint:_hint
                         additionalScopes:additionalScopes
                                 callback:callback];
@@ -1254,7 +1254,7 @@ static void *kTestObserverContext = &kTestObserverContext;
                 presentingViewController:_presentingViewController
 #elif TARGET_OS_OSX
                         presentingWindow:_presentingWindow
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                     hint:_hint
                                 callback:callback];
       }
@@ -1273,15 +1273,15 @@ static void *kTestObserverContext = &kTestObserverContext;
     XCTAssertEqual(_savedPresentingViewController, _presentingViewController);
 #elif TARGET_OS_OSX
     XCTAssertEqual(_savedPresentingWindow, _presentingWindow);
-#endif
+#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
     // maybeFetchToken
     if (!(authError || modalCancel)) {
       [[[_authState expect] andReturn:nil] lastTokenResponse];
-#if TARGET_OS_IOS
+#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
       // Corresponds to EMM support
       [[[_authState expect] andReturn:authResponse] lastAuthorizationResponse];
-#endif
+#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
       [[[_authState expect] andReturn:nil] lastTokenResponse];
       [[[_authState expect] andReturn:authResponse] lastAuthorizationResponse];
       [[[_authState expect] andReturn:authResponse] lastAuthorizationResponse];