diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index d2ec3f52..27ac78d1 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -39,13 +39,15 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-12] + os: [macos-14] sdk: ['macosx', 'iphonesimulator'] include: - sdk: 'macosx' destination: '"platform=OS X,arch=x86_64"' - sdk: 'iphonesimulator' destination: '"platform=iOS Simulator,name=iPhone 11"' + - sdk: 'xrsimulator' + destination: '"platform=visionOS simulator,name=Any visionOS Simulator Device"' steps: - uses: actions/checkout@v3 - name: Build unit test target diff --git a/GoogleSignIn/Sources/GIDGoogleUser.m b/GoogleSignIn/Sources/GIDGoogleUser.m index ec300839..7005371e 100644 --- a/GoogleSignIn/Sources/GIDGoogleUser.m +++ b/GoogleSignIn/Sources/GIDGoogleUser.m @@ -173,7 +173,7 @@ - (void)refreshTokensIfNeededWithCompletion:(GIDGoogleUserCompletion)completion }); } }]; -#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST +#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST || TARGET_OS_VISION NSArray *refreshTokensHandlerQueue; @synchronized(self->_tokenRefreshHandlerQueue) { refreshTokensHandlerQueue = [self->_tokenRefreshHandlerQueue copy]; @@ -193,11 +193,11 @@ - (OIDAuthState *)authState { } - (void)addScopes:(NSArray *)scopes -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:(UIViewController *)presentingViewController #elif TARGET_OS_OSX presentingWindow:(NSWindow *)presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult, NSError *_Nullable error))completion { if (self != GIDSignIn.sharedInstance.currentUser) { @@ -213,11 +213,11 @@ - (void)addScopes:(NSArray *)scopes } [GIDSignIn.sharedInstance addScopes:scopes -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:presentingViewController #elif TARGET_OS_OSX presentingWindow:presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION completion:completion]; } diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index 4b942ed9..47eb3694 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -30,7 +30,7 @@ #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST #import "GoogleSignIn/Sources/GIDAuthStateMigration.h" #import "GoogleSignIn/Sources/GIDEMMErrorHandler.h" -#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST || TARGET_OS_VISION #import "GoogleSignIn/Sources/GIDGoogleUser_Private.h" #import "GoogleSignIn/Sources/GIDProfileData_Private.h" @@ -56,7 +56,7 @@ #import #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import #elif TARGET_OS_OSX #import @@ -235,7 +235,7 @@ - (BOOL)restorePreviousSignInNoRefresh { return YES; } -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController hint:(nullable NSString *)hint @@ -565,7 +565,7 @@ - (void)authenticateInteractivelyWithOptions:(GIDSignInInternalOptions *)options NSString *emmSupport; #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST emmSupport = [[self class] isOperatingSystemAtLeast9] ? kEMMVersion : nil; -#elif TARGET_OS_MACCATALYST || TARGET_OS_OSX +#elif TARGET_OS_MACCATALYST || TARGET_OS_OSX || TARGET_OS_VISION emmSupport = nil; #endif // TARGET_OS_MACCATALYST || TARGET_OS_OSX @@ -586,7 +586,7 @@ - (void)authenticateInteractivelyWithOptions:(GIDSignInInternalOptions *)options [GIDEMMSupport parametersWithParameters:options.extraParams emmSupport:emmSupport isPasscodeInfoRequired:NO]]; -#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST +#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST || TARGET_OS_VISION [additionalParameters addEntriesFromDictionary:options.extraParams]; #endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST additionalParameters[kSDKVersionLoggingParameter] = GIDVersion(); @@ -602,7 +602,7 @@ - (void)authenticateInteractivelyWithOptions:(GIDSignInInternalOptions *)options _currentAuthorizationFlow = [OIDAuthorizationService presentAuthorizationRequest:request -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:options.presentingViewController #elif TARGET_OS_OSX presentingWindow:options.presentingWindow @@ -639,7 +639,7 @@ - (void)processAuthorizationResponse:(OIDAuthorizationResponse *)authorizationRe GIDSignInErrorCode errorCode = kGIDSignInErrorCodeUnknown; NSDictionary *params = authorizationResponse.additionalParameters; -#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST +#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION if (authFlow.emmSupport) { [authFlow wait]; BOOL isEMMError = [[GIDEMMErrorHandler sharedInstance] @@ -767,7 +767,7 @@ - (void)maybeFetchToken:(GIDAuthFlow *)authFlow { } else { [authFlow next]; } -#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST +#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST || TARGET_OS_VISION [authFlow next]; #endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST }]; @@ -905,7 +905,7 @@ - (BOOL)handleDevicePolicyAppURL:(NSURL *)url { if (![@"restart_auth" isEqualToString:actionString]) { return NO; } -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION if (!_currentOptions.presentingViewController) { return NO; } @@ -963,7 +963,7 @@ - (void)assertValidParameters { // Assert that the presenting view controller has been set. - (void)assertValidPresentingViewController { -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION if (!_currentOptions.presentingViewController) #elif TARGET_OS_OSX if (!_currentOptions.presentingWindow) diff --git a/GoogleSignIn/Sources/GIDSignInButton.m b/GoogleSignIn/Sources/GIDSignInButton.m index 2d78330b..22e42c68 100644 --- a/GoogleSignIn/Sources/GIDSignInButton.m +++ b/GoogleSignIn/Sources/GIDSignInButton.m @@ -14,7 +14,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h" @@ -644,4 +644,4 @@ - (UIImage *)gid_imageWithBlendMode:(CGBlendMode)blendMode color:(UIColor *)colo NS_ASSUME_NONNULL_END -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION diff --git a/GoogleSignIn/Sources/GIDSignInInternalOptions.h b/GoogleSignIn/Sources/GIDSignInInternalOptions.h index f1aff409..5735712e 100644 --- a/GoogleSignIn/Sources/GIDSignInInternalOptions.h +++ b/GoogleSignIn/Sources/GIDSignInInternalOptions.h @@ -47,13 +47,13 @@ NS_ASSUME_NONNULL_BEGIN /// The configuration to use during the flow. @property(nonatomic, readonly, nullable) GIDConfiguration *configuration; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION /// The view controller to use during the flow. @property(nonatomic, readonly, weak, nullable) UIViewController *presentingViewController; #elif TARGET_OS_OSX /// The window to use during the flow. @property(nonatomic, readonly, weak, nullable) NSWindow *presentingWindow; -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION /// The completion block to be called at the completion of the flow. @property(nonatomic, readonly, nullable) GIDSignInCompletion completion; @@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, copy, nullable) NSString *loginHint; /// Creates the default options. -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration presentingViewController:(nullable UIViewController *)presentingViewController loginHint:(nullable NSString *)loginHint @@ -92,7 +92,7 @@ NS_ASSUME_NONNULL_BEGIN addScopesFlow:(BOOL)addScopesFlow scopes:(nullable NSArray *)scopes completion:(nullable GIDSignInCompletion)completion; -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION /// Creates the options to sign in silently. + (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion; diff --git a/GoogleSignIn/Sources/GIDSignInInternalOptions.m b/GoogleSignIn/Sources/GIDSignInInternalOptions.m index bfb21643..3514780f 100644 --- a/GoogleSignIn/Sources/GIDSignInInternalOptions.m +++ b/GoogleSignIn/Sources/GIDSignInInternalOptions.m @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN @implementation GIDSignInInternalOptions -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration presentingViewController:(nullable UIViewController *)presentingViewController loginHint:(nullable NSString *)loginHint @@ -39,18 +39,18 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con addScopesFlow:(BOOL)addScopesFlow scopes:(nullable NSArray *)scopes completion:(nullable GIDSignInCompletion)completion { -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init]; if (options) { options->_interactive = YES; options->_continuation = NO; options->_addScopesFlow = addScopesFlow; options->_configuration = configuration; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION options->_presentingViewController = presentingViewController; #elif TARGET_OS_OSX options->_presentingWindow = presentingWindow; -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION options->_loginHint = loginHint; options->_completion = completion; options->_scopes = [GIDScopes scopesWithBasicProfile:scopes]; @@ -58,7 +58,7 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con return options; } -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration presentingViewController:(nullable UIViewController *)presentingViewController loginHint:(nullable NSString *)loginHint @@ -70,13 +70,13 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con loginHint:(nullable NSString *)loginHint addScopesFlow:(BOOL)addScopesFlow completion:(nullable GIDSignInCompletion)completion { -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:configuration -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:presentingViewController #elif TARGET_OS_OSX presentingWindow:presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION loginHint:loginHint addScopesFlow:addScopesFlow scopes:@[] @@ -86,11 +86,11 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con + (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion { GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:nil -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:nil #elif TARGET_OS_OSX presentingWindow:nil -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION loginHint:nil addScopesFlow:NO completion:completion]; @@ -108,11 +108,11 @@ - (instancetype)optionsWithExtraParameters:(NSDictionary *)extraParams options->_continuation = continuation; options->_addScopesFlow = _addScopesFlow; options->_configuration = _configuration; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION options->_presentingViewController = _presentingViewController; #elif TARGET_OS_OSX options->_presentingWindow = _presentingWindow; -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION options->_loginHint = _loginHint; options->_completion = _completion; options->_scopes = _scopes; diff --git a/GoogleSignIn/Sources/GIDSignInPreferences.m b/GoogleSignIn/Sources/GIDSignInPreferences.m index 3f0e27d1..2b19c874 100644 --- a/GoogleSignIn/Sources/GIDSignInPreferences.m +++ b/GoogleSignIn/Sources/GIDSignInPreferences.m @@ -33,6 +33,7 @@ static NSString *const kAppleEnvironmentMacOS = @"macos"; static NSString *const kAppleEnvironmentMacOSIOSOnMac = @"macos-ios"; static NSString *const kAppleEnvironmentMacOSMacCatalyst = @"macos-cat"; +static NSString *const kAppleEnvironmentVisionOS = @"visionos"; #ifndef GID_SDK_VERSION #error "GID_SDK_VERSION is not defined: add -DGID_SDK_VERSION=x.x.x to the build invocation." @@ -75,6 +76,8 @@ #endif // TARGET_OS_SIMULATOR #elif TARGET_OS_OSX appleEnvironment = kAppleEnvironmentMacOS; +#elif TARGET_OS_VISION + appleEnvironment = kAppleEnvironmentVisionOS; #endif // TARGET_OS_MACCATALYST return appleEnvironment; diff --git a/GoogleSignIn/Sources/GIDSignIn_Private.h b/GoogleSignIn/Sources/GIDSignIn_Private.h index 2fb71ae4..724dff5b 100644 --- a/GoogleSignIn/Sources/GIDSignIn_Private.h +++ b/GoogleSignIn/Sources/GIDSignIn_Private.h @@ -61,7 +61,7 @@ typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error); /// @return NO if there is no user restored from the keychain. - (BOOL)restorePreviousSignInNoRefresh; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION /// Starts an interactive consent flow on iOS to add scopes to the current user's grants. /// diff --git a/GoogleSignIn/Sources/NSBundle+GID3PAdditions.m b/GoogleSignIn/Sources/NSBundle+GID3PAdditions.m index 5660d0ba..46441df6 100644 --- a/GoogleSignIn/Sources/NSBundle+GID3PAdditions.m +++ b/GoogleSignIn/Sources/NSBundle+GID3PAdditions.m @@ -50,12 +50,12 @@ + (void)gid_registerFonts { NSArray* allFontNames = @[ @"Roboto-Bold" ]; NSBundle* bundle = [self gid_frameworkBundle]; for (NSString *fontName in allFontNames) { -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // Check to see if the font is already here, and skip registration if so. if ([UIFont fontWithName:fontName size:[UIFont systemFontSize]]) { // size doesn't matter continue; } -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // Load the font data file from the bundle. NSString *path = [bundle pathForResource:fontName ofType:@"ttf"]; diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h index a7026366..dd73b93e 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h @@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)refreshTokensIfNeededWithCompletion:(void (^)(GIDGoogleUser *_Nullable user, NSError *_Nullable error))completion; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION /// Starts an interactive consent flow on iOS to add new scopes to the user's `grantedScopes`. /// diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 2576b13d..c0fc2ae0 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -104,7 +104,7 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) { /// This block will be called asynchronously on the main queue. - (void)disconnectWithCompletion:(nullable void (^)(NSError *_Nullable error))completion; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION /// Starts an interactive sign-in flow on iOS. /// diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h index f27488fb..1294b004 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h @@ -15,7 +15,7 @@ */ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h index 5923329d..446058f1 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#import #import "GIDConfiguration.h" #import "GIDGoogleUser.h" @@ -21,6 +20,4 @@ #import "GIDSignIn.h" #import "GIDToken.h" #import "GIDSignInResult.h" -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST #import "GIDSignInButton.h" -#endif diff --git a/GoogleSignIn/Tests/Unit/GIDConfigurationTest.m b/GoogleSignIn/Tests/Unit/GIDConfigurationTest.m index 3c24b5e4..a042678c 100644 --- a/GoogleSignIn/Tests/Unit/GIDConfigurationTest.m +++ b/GoogleSignIn/Tests/Unit/GIDConfigurationTest.m @@ -95,7 +95,7 @@ - (void)testCoding { } } -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // Deprecated in iOS 13 and macOS 10.14 - (void)testLegacyCoding { GIDConfiguration *configuration = [GIDConfiguration testInstance]; @@ -104,6 +104,6 @@ - (void)testLegacyCoding { XCTAssertEqualObjects(configuration, newConfiguration); XCTAssertTrue(GIDConfiguration.supportsSecureCoding); } -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION @end diff --git a/GoogleSignIn/Tests/Unit/GIDGoogleUserTest.m b/GoogleSignIn/Tests/Unit/GIDGoogleUserTest.m index f987c7c1..928507a0 100644 --- a/GoogleSignIn/Tests/Unit/GIDGoogleUserTest.m +++ b/GoogleSignIn/Tests/Unit/GIDGoogleUserTest.m @@ -128,7 +128,7 @@ - (void)testCoding { } } -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // Deprecated in iOS 13 and macOS 10.14 - (void)testLegacyCoding { GIDGoogleUser *user = [[GIDGoogleUser alloc] initWithAuthState:[OIDAuthState testInstance] @@ -138,7 +138,7 @@ - (void)testLegacyCoding { XCTAssertEqualObjects(user, newUser); XCTAssertTrue(GIDGoogleUser.supportsSecureCoding); } -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // Test the old encoding format for backword compatability. - (void)testOldFormatCoding { @@ -456,11 +456,11 @@ - (void)testAddScopes_success { id signIn = OCMClassMock([GIDSignIn class]); OCMStub([signIn sharedInstance]).andReturn(signIn); [[signIn expect] addScopes:OCMOCK_ANY -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:OCMOCK_ANY #elif TARGET_OS_OSX presentingWindow:OCMOCK_ANY -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION completion:OCMOCK_ANY]; GIDGoogleUser *currentUser = [self googleUserWithAccessTokenExpiresIn:kAccessTokenExpiresIn @@ -469,11 +469,11 @@ - (void)testAddScopes_success { OCMStub([signIn currentUser]).andReturn(currentUser); [currentUser addScopes:@[kNewScope] -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:[[UIViewController alloc] init] #elif TARGET_OS_OSX presentingWindow:[[NSWindow alloc] init] -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION completion:nil]; [signIn verify]; @@ -495,11 +495,11 @@ - (void)testAddScopes_failure_addScopesToPreviousUser { [self expectationWithDescription:@"Completion is called."]; [previousUser addScopes:@[kNewScope] -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:[[UIViewController alloc] init] #elif TARGET_OS_OSX presentingWindow:[[NSWindow alloc] init] -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION completion:^(GIDSignInResult *signInResult, NSError *error) { [expectation fulfill]; XCTAssertNil(signInResult); @@ -523,11 +523,11 @@ - (void)testAddScopes_failure_addScopesToPreviousUser_currentUserIsNull { [self expectationWithDescription:@"Completion is called."]; [previousUser addScopes:@[kNewScope] -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:[[UIViewController alloc] init] #elif TARGET_OS_OSX presentingWindow:[[NSWindow alloc] init] -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION completion:^(GIDSignInResult *signInResult, NSError *error) { [expectation fulfill]; XCTAssertNil(signInResult); diff --git a/GoogleSignIn/Tests/Unit/GIDProfileDataTest.m b/GoogleSignIn/Tests/Unit/GIDProfileDataTest.m index 10486693..bec2fc5b 100644 --- a/GoogleSignIn/Tests/Unit/GIDProfileDataTest.m +++ b/GoogleSignIn/Tests/Unit/GIDProfileDataTest.m @@ -133,7 +133,7 @@ - (void)testOldArchiveFormat { } } -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // Deprecated in iOS 13 and macOS 10.14 - (void)testLegacyCoding { @@ -160,7 +160,7 @@ - (void)testOldArchiveFormatLegacy { kFIFEImageURLWithDimension); } -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION - (void)testImageURLWithDimension { GIDProfileData *profileData; diff --git a/GoogleSignIn/Tests/Unit/GIDSignInButtonTest.m b/GoogleSignIn/Tests/Unit/GIDSignInButtonTest.m index 658356e3..08c74029 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInButtonTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInButtonTest.m @@ -13,7 +13,7 @@ // limitations under the License. #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import #import @@ -206,4 +206,4 @@ - (void)testDontRemoveValidHeightConstraint { @end -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION diff --git a/GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m b/GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m index bcc48910..b3a2870b 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m @@ -31,22 +31,22 @@ @implementation GIDSignInInternalOptionsTest - (void)testDefaultOptions { id configuration = OCMStrictClassMock([GIDConfiguration class]); -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION id presentingViewController = OCMStrictClassMock([UIViewController class]); #elif TARGET_OS_OSX id presentingWindow = OCMStrictClassMock([NSWindow class]); -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION NSString *loginHint = @"login_hint"; GIDSignInCompletion completion = ^(GIDSignInResult *_Nullable signInResult, NSError * _Nullable error) {}; GIDSignInInternalOptions *options = [GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:presentingViewController #elif TARGET_OS_OSX presentingWindow:presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION loginHint:loginHint addScopesFlow:NO completion:completion]; @@ -56,11 +56,11 @@ - (void)testDefaultOptions { XCTAssertNil(options.extraParams); OCMVerifyAll(configuration); -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION OCMVerifyAll(presentingViewController); #elif TARGET_OS_OSX OCMVerifyAll(presentingWindow); -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION } - (void)testSilentOptions { diff --git a/GoogleSignIn/Tests/Unit/GIDSignInPreferencesTest.m b/GoogleSignIn/Tests/Unit/GIDSignInPreferencesTest.m index 80fa8949..0a6a9764 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInPreferencesTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInPreferencesTest.m @@ -40,6 +40,8 @@ - (void)testGIDEnvironment { #endif // TARGET_OS_SIMULATOR #elif TARGET_OS_OSX expectedEnvironment = @"macos"; +#elif TARGET_OS_VISION + expectedEnvironment = @"visionos"; #endif // TARGET_OS_MACCATALYST XCTAssertEqualObjects(environment, expectedEnvironment); } diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index c64f1611..e6da20df 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -13,11 +13,11 @@ // limitations under the License. #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import #elif TARGET_OS_OSX #import -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import @@ -58,11 +58,11 @@ #import #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import #elif TARGET_OS_OSX #import -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import #import @@ -152,7 +152,7 @@ static NSString *const kGrantedScope = @"grantedScope"; static NSString *const kNewScope = @"newScope"; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // This category is used to allow the test to swizzle a private method. @interface UIViewController (Testing) @@ -161,7 +161,7 @@ @interface UIViewController (Testing) - (UIWindow *)_window; @end -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // This class extension exposes GIDSignIn methods to our tests. @interface GIDSignIn () @@ -195,13 +195,13 @@ @interface GIDSignInTest : XCTestCase { // Mock |GTMKeychainStore|. id _keychainStore; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // Mock |UIViewController|. id _presentingViewController; #elif TARGET_OS_OSX // Mock |NSWindow|. id _presentingWindow; -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // Mock for |GIDGoogleUser|. id _user; @@ -242,13 +242,13 @@ @interface GIDSignInTest : XCTestCase { // The saved authorization request. OIDAuthorizationRequest *_savedAuthorizationRequest; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // The saved presentingViewController from the authorization request. UIViewController *_savedPresentingViewController; #elif TARGET_OS_OSX // The saved presentingWindow from the authorization request. NSWindow *_savedPresentingWindow; -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // The saved authorization callback. OIDAuthorizationCallback _savedAuthorizationCallback; @@ -281,11 +281,11 @@ - (void)setUp { _keychainRemoved = NO; // Mocks -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION _presentingViewController = OCMStrictClassMock([UIViewController class]); #elif TARGET_OS_OSX _presentingWindow = OCMStrictClassMock([NSWindow class]); -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION _authState = OCMStrictClassMock([OIDAuthState class]); OCMStub([_authState alloc]).andReturn(_authState); OCMStub([_authState initWithAuthorizationResponse:OCMOCK_ANY]).andReturn(_authState); @@ -308,11 +308,11 @@ - (void)setUp { _oidAuthorizationService = OCMStrictClassMock([OIDAuthorizationService class]); OCMStub([_oidAuthorizationService presentAuthorizationRequest:SAVE_TO_ARG_BLOCK(self->_savedAuthorizationRequest) -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:SAVE_TO_ARG_BLOCK(self->_savedPresentingViewController) #elif TARGET_OS_OSX presentingWindow:SAVE_TO_ARG_BLOCK(self->_savedPresentingWindow) -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION callback:COPY_TO_ARG_BLOCK(self->_savedAuthorizationCallback)]); OCMStub([self->_oidAuthorizationService performTokenRequest:SAVE_TO_ARG_BLOCK(self->_savedTokenRequest) @@ -351,11 +351,11 @@ - (void)tearDown { OCMVerifyAll(_user); OCMVerifyAll(_oidAuthorizationService); -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION OCMVerifyAll(_presentingViewController); #elif TARGET_OS_OSX OCMVerifyAll(_presentingWindow); -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION [_fakeMainBundle stopFaking]; @@ -1003,18 +1003,18 @@ - (void)testDisconnectNoCallback_noTokens { } - (void)testPresentingViewControllerException { -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION _presentingViewController = nil; #elif TARGET_OS_OSX _presentingWindow = nil; -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION XCTAssertThrows([_signIn signInWithPresentingViewController:_presentingViewController #elif TARGET_OS_OSX XCTAssertThrows([_signIn signInWithPresentingWindow:_presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION hint:_hint completion:_completion]); } @@ -1026,11 +1026,11 @@ - (void)testClientIDMissingException { #pragma GCC diagnostic pop BOOL threw = NO; @try { -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION [_signIn signInWithPresentingViewController:_presentingViewController #elif TARGET_OS_OSX [_signIn signInWithPresentingWindow:_presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION completion:nil]; } @catch (NSException *exception) { threw = YES; @@ -1045,11 +1045,11 @@ - (void)testSchemesNotSupportedException { [_fakeMainBundle fakeMissingAllSchemes]; BOOL threw = NO; @try { -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION [_signIn signInWithPresentingViewController:_presentingViewController #elif TARGET_OS_OSX [_signIn signInWithPresentingWindow:_presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION hint:_hint completion:_completion]; } @catch (NSException *exception) { @@ -1378,28 +1378,28 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow }; if (addScopesFlow) { [_signIn addScopes:@[kNewScope] -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION presentingViewController:_presentingViewController #elif TARGET_OS_OSX presentingWindow:_presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION completion:completion]; } else { if (useAdditionalScopes) { -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION [_signIn signInWithPresentingViewController:_presentingViewController #elif TARGET_OS_OSX [_signIn signInWithPresentingWindow:_presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION hint:_hint additionalScopes:additionalScopes completion:completion]; } else { -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION [_signIn signInWithPresentingViewController:_presentingViewController #elif TARGET_OS_OSX [_signIn signInWithPresentingWindow:_presentingWindow -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION hint:_hint completion:completion]; } @@ -1414,11 +1414,11 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow XCTAssertEqualObjects(params[kSDKVersionLoggingParameter], GIDVersion()); XCTAssertEqualObjects(params[kEnvironmentLoggingParameter], GIDEnvironment()); XCTAssertNotNil(_savedAuthorizationCallback); -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION XCTAssertEqual(_savedPresentingViewController, _presentingViewController); #elif TARGET_OS_OSX XCTAssertEqual(_savedPresentingWindow, _presentingWindow); -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION // maybeFetchToken if (!(authError || modalCancel)) { diff --git a/GoogleSignInSwift/Sources/GoogleSignInButton.swift b/GoogleSignInSwift/Sources/GoogleSignInButton.swift index aec05d29..7a786bb2 100644 --- a/GoogleSignInSwift/Sources/GoogleSignInButton.swift +++ b/GoogleSignInSwift/Sources/GoogleSignInButton.swift @@ -133,7 +133,7 @@ private extension Image { ) else { fatalError("Unable to load Google icon image url: \(Image.Error.unableToLoadGoogleIcon(name: googleImageName))") } -#if os(iOS) || targetEnvironment(macCatalyst) +#if os(iOS) || targetEnvironment(macCatalyst) || os(visionOS) guard let uiImage = UIImage(contentsOfFile: iconURL.path) else { fatalError("Unable to load Google icon image url: \(Image.Error.unableToLoadGoogleIcon(name: googleImageName))") } @@ -172,7 +172,7 @@ private extension Font { /// - returns A `Bool` indicating whether or not the font was loaded. static func loadCGFont() -> Bool { // Check to see if the font has already been loaded -#if os(iOS) || targetEnvironment(macCatalyst) +#if os(iOS) || targetEnvironment(macCatalyst) || os(visionOS) if let _ = UIFont(name: fontNameRobotoBold, size: fontSize) { return true } diff --git a/GoogleSignInSwift/Sources/GoogleSignInButtonStyling.swift b/GoogleSignInSwift/Sources/GoogleSignInButtonStyling.swift index 344b2201..22009f52 100644 --- a/GoogleSignInSwift/Sources/GoogleSignInButtonStyling.swift +++ b/GoogleSignInSwift/Sources/GoogleSignInButtonStyling.swift @@ -235,7 +235,7 @@ extension GoogleSignInButtonStyle { let bt = buttonText as NSString let size = CGSize(width: .max, height: .max) let anyFont: Any -#if os(iOS) || targetEnvironment(macCatalyst) +#if os(iOS) || targetEnvironment(macCatalyst) || os(visionOS) anyFont = UIFont(name: fontNameRobotoBold, size: fontSize) as Any #elseif os(macOS) anyFont = NSFont(name: fontNameRobotoBold, size: fontSize) as Any diff --git a/Package.swift b/Package.swift index 8336f199..c1e68af6 100644 --- a/Package.swift +++ b/Package.swift @@ -43,8 +43,8 @@ let package = Package( dependencies: [ .package( name: "AppAuth", - url: "https://github.com/openid/AppAuth-iOS.git", - from: "1.7.3"), + url: "https://github.com/paulb777/AppAuth-iOS.git", + .revision("b866746")), .package( name: "GTMAppAuth", url: "https://github.com/google/GTMAppAuth.git",