Skip to content

Commit 47fa877

Browse files
authored
Fix and normalize TARGET_OS macro references. (google#129)
1 parent e6e8c8a commit 47fa877

24 files changed

Lines changed: 121 additions & 115 deletions

GoogleSignIn/Sources/GIDAuthentication.m

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
#import "GoogleSignIn/Sources/GIDSignInPreferences.h"
2020

21-
#if TARGET_OS_IOS
21+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
2222
#import "GoogleSignIn/Sources/GIDEMMErrorHandler.h"
2323
#import "GoogleSignIn/Sources/GIDMDMPasscodeState.h"
24-
#endif
24+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
2525

2626
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h"
2727

@@ -57,7 +57,7 @@
5757
// New UIDevice system name for iOS.
5858
static NSString *const kNewIOSSystemName = @"iOS";
5959

60-
#if TARGET_OS_IOS
60+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
6161

6262
// The specialized GTMAppAuthFetcherAuthorization delegate that handles potential EMM error
6363
// responses.
@@ -149,7 +149,7 @@ - (void)authorizeRequest:(nullable NSMutableURLRequest *)request
149149

150150
@end
151151

152-
#endif
152+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
153153

154154
@implementation GIDAuthentication {
155155
// A queue for pending authentication handlers so we don't fire multiple requests in parallel.
@@ -197,24 +197,24 @@ - (nullable NSDate *)idTokenExpirationDate {
197197

198198
#pragma mark - Private property accessors
199199

200-
#if TARGET_OS_IOS
200+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
201201
- (NSString *)emmSupport {
202202
return
203203
_authState.lastAuthorizationResponse.request.additionalParameters[kEMMSupportParameterName];
204204
}
205-
#endif
205+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
206206

207207
#pragma mark - Public methods
208208

209209
- (id<GTMFetcherAuthorizationProtocol>)fetcherAuthorizer {
210-
#if TARGET_OS_IOS
210+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
211211
GTMAppAuthFetcherAuthorization *authorization = self.emmSupport ?
212212
[[GTMAppAuthFetcherAuthorizationWithEMMSupport alloc] initWithAuthState:_authState] :
213213
[[GTMAppAuthFetcherAuthorization alloc] initWithAuthState:_authState];
214-
#else // TARGET_OS_OSX or TARGET_OS_MACCATALYST
214+
#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
215215
GTMAppAuthFetcherAuthorization *authorization =
216216
[[GTMAppAuthFetcherAuthorization alloc] initWithAuthState:_authState];
217-
#endif
217+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
218218
authorization.tokenRefreshDelegate = self;
219219
return authorization;
220220
}
@@ -237,14 +237,14 @@ - (void)doWithFreshTokens:(GIDAuthenticationAction)action {
237237
}
238238
// This is the first handler in the queue, a fetch is needed.
239239
NSMutableDictionary *additionalParameters = [@{} mutableCopy];
240-
#if TARGET_OS_IOS
240+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
241241
[additionalParameters addEntriesFromDictionary:
242242
[GIDAuthentication updatedEMMParametersWithParameters:
243243
_authState.lastTokenResponse.request.additionalParameters]];
244-
#else // TARGET_OS_OSX or TARGET_OS_MACCATALYST
244+
#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
245245
[additionalParameters addEntriesFromDictionary:
246246
_authState.lastTokenResponse.request.additionalParameters];
247-
#endif
247+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
248248
additionalParameters[kSDKVersionLoggingParameter] = GIDVersion();
249249
additionalParameters[kEnvironmentLoggingParameter] = GIDEnvironment();
250250

@@ -269,7 +269,7 @@ - (void)doWithFreshTokens:(GIDAuthenticationAction)action {
269269
[self->_authState updateWithAuthorizationError:error];
270270
}
271271
}
272-
#if TARGET_OS_IOS
272+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
273273
[GIDAuthentication handleTokenFetchEMMError:error completion:^(NSError *_Nullable error) {
274274
// Process the handler queue to call back.
275275
NSArray *authenticationHandlerQueue;
@@ -283,7 +283,7 @@ - (void)doWithFreshTokens:(GIDAuthenticationAction)action {
283283
});
284284
}
285285
}];
286-
#else // TARGET_OS_OSX or TARGET_OS_MACCATALYST
286+
#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
287287
NSArray *authenticationHandlerQueue;
288288
@synchronized(self->_authenticationHandlerQueue) {
289289
authenticationHandlerQueue = [self->_authenticationHandlerQueue copy];
@@ -294,12 +294,14 @@ - (void)doWithFreshTokens:(GIDAuthenticationAction)action {
294294
action(error ? nil : self, error);
295295
});
296296
}
297-
#endif
297+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
298298
}];
299299
}
300300

301301
#pragma mark - Private methods
302-
#if TARGET_OS_IOS
302+
303+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
304+
303305
+ (NSDictionary *)parametersWithParameters:(NSDictionary *)parameters
304306
emmSupport:(nullable NSString *)emmSupport
305307
isPasscodeInfoRequired:(BOOL)isPasscodeInfoRequired {
@@ -346,18 +348,19 @@ + (void)handleTokenFetchEMMError:(nullable NSError *)error
346348
completion(error);
347349
}
348350
}
349-
#endif
351+
352+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
350353

351354
#pragma mark - GTMAppAuthFetcherAuthorizationTokenRefreshDelegate
352355

353356
- (nullable NSDictionary *)additionalRefreshParameters:
354357
(GTMAppAuthFetcherAuthorization *)authorization {
355-
#if TARGET_OS_IOS
358+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
356359
return [GIDAuthentication updatedEMMParametersWithParameters:
357360
authorization.authState.lastTokenResponse.request.additionalParameters];
358-
#else // TARGET_OS_MACCATALYST or TARGET_OS_OSX
361+
#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
359362
return authorization.authState.lastTokenResponse.request.additionalParameters;
360-
#endif
363+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
361364
}
362365

363366
#pragma mark - NSSecureCoding

GoogleSignIn/Sources/GIDAuthentication_Private.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ NS_ASSUME_NONNULL_BEGIN
3232
// A representation of the state of the OAuth session for this instance.
3333
@property(nonatomic, readonly) OIDAuthState *authState;
3434

35-
#if TARGET_OS_IOS
35+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
3636
// A string indicating support for Enterprise Mobility Management.
3737
@property(nonatomic, readonly) NSString *emmSupport;
38-
#endif
38+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
3939

4040
- (instancetype)initWithAuthState:(OIDAuthState *)authState;
4141

42-
#if TARGET_OS_IOS
42+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
4343
// Gets a new set of URL parameters that also contains EMM-related URL parameters if needed.
4444
+ (NSDictionary *)parametersWithParameters:(NSDictionary *)parameters
4545
emmSupport:(nullable NSString *)emmSupport
@@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
5151
// Handles potential EMM error from token fetch response.
5252
+ (void)handleTokenFetchEMMError:(nullable NSError *)error
5353
completion:(void (^)(NSError *_Nullable))completion;
54-
#endif
54+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
5555

5656
@end
5757

GoogleSignIn/Sources/GIDEMMErrorHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
#import <TargetConditionals.h>
1717

18-
#if TARGET_OS_IOS
18+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1919

2020
#import <Foundation/Foundation.h>
2121

@@ -39,4 +39,4 @@ NS_ASSUME_NONNULL_BEGIN
3939

4040
NS_ASSUME_NONNULL_END
4141

42-
#endif
42+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

GoogleSignIn/Sources/GIDEMMErrorHandler.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414
#import <TargetConditionals.h>
1515

16-
#if TARGET_OS_IOS
16+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1717

1818
#import "GoogleSignIn/Sources/GIDEMMErrorHandler.h"
1919

@@ -336,4 +336,4 @@ - (NSString *)cancelString {
336336

337337
NS_ASSUME_NONNULL_END
338338

339-
#endif
339+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

GoogleSignIn/Sources/GIDMDMPasscodeCache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
#import <TargetConditionals.h>
1717

18-
#if TARGET_OS_IOS
18+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1919

2020
#import <Foundation/Foundation.h>
2121

@@ -43,4 +43,4 @@ NS_ASSUME_NONNULL_BEGIN
4343

4444
NS_ASSUME_NONNULL_END
4545

46-
#endif
46+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

GoogleSignIn/Sources/GIDMDMPasscodeCache.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414
#import <TargetConditionals.h>
1515

16-
#if TARGET_OS_IOS
16+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1717

1818
#import "GoogleSignIn/Sources/GIDMDMPasscodeCache.h"
1919

@@ -298,4 +298,4 @@ - (NSString *)info {
298298

299299
NS_ASSUME_NONNULL_END
300300

301-
#endif
301+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

GoogleSignIn/Sources/GIDMDMPasscodeState.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
#import <TargetConditionals.h>
1717

18-
#if TARGET_OS_IOS
18+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1919

2020
#import <Foundation/Foundation.h>
2121

@@ -51,4 +51,4 @@ NS_ASSUME_NONNULL_BEGIN
5151

5252
NS_ASSUME_NONNULL_END
5353

54-
#endif
54+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

GoogleSignIn/Sources/GIDMDMPasscodeState.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414
#import <TargetConditionals.h>
1515

16-
#if TARGET_OS_IOS
16+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1717

1818
#import "GoogleSignIn/Sources/GIDMDMPasscodeState.h"
1919

@@ -52,4 +52,4 @@ + (instancetype)passcodeState {
5252

5353
NS_ASSUME_NONNULL_END
5454

55-
#endif
55+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

GoogleSignIn/Sources/GIDMDMPasscodeState_Private.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
#import <TargetConditionals.h>
1717

18-
#if TARGET_OS_IOS
18+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1919

2020
#import <Foundation/Foundation.h>
2121

@@ -37,4 +37,4 @@ NS_ASSUME_NONNULL_BEGIN
3737

3838
NS_ASSUME_NONNULL_END
3939

40-
#endif
40+
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST

0 commit comments

Comments
 (0)