Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vision OS Proof of Concept #415

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions GoogleSignIn/Sources/GIDGoogleUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<GIDGoogleUserCompletion> *refreshTokensHandlerQueue;
@synchronized(self->_tokenRefreshHandlerQueue) {
refreshTokensHandlerQueue = [self->_tokenRefreshHandlerQueue copy];
Expand All @@ -193,11 +193,11 @@ - (OIDAuthState *)authState {
}

- (void)addScopes:(NSArray<NSString *> *)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) {
Expand All @@ -213,11 +213,11 @@ - (void)addScopes:(NSArray<NSString *> *)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];
}

Expand Down
20 changes: 10 additions & 10 deletions GoogleSignIn/Sources/GIDSignIn.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -56,7 +56,7 @@
#import <AppAuth/OIDURLQueryComponent.h>
#import <GTMSessionFetcher/GTMSessionFetcher.h>

#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
#import <AppAuth/OIDAuthorizationService+IOS.h>
#elif TARGET_OS_OSX
#import <AppAuth/OIDAuthorizationService+Mac.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -639,7 +639,7 @@ - (void)processAuthorizationResponse:(OIDAuthorizationResponse *)authorizationRe
GIDSignInErrorCode errorCode = kGIDSignInErrorCodeUnknown;
NSDictionary<NSString *, NSObject *> *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]
Expand Down Expand Up @@ -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
}];
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions GoogleSignIn/Sources/GIDSignInButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#import <TargetConditionals.h>

#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION

#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h"

Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions GoogleSignIn/Sources/GIDSignInInternalOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions GoogleSignIn/Sources/GIDSignInInternalOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,26 +39,26 @@ + (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];
}
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
Expand All @@ -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:@[]
Expand All @@ -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];
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions GoogleSignIn/Sources/GIDSignInPreferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GoogleSignIn/Sources/GIDSignIn_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
4 changes: 2 additions & 2 deletions GoogleSignIn/Sources/NSBundle+GID3PAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
2 changes: 1 addition & 1 deletion GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
///
Expand Down
2 changes: 1 addition & 1 deletion GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#import <TargetConditionals.h>

#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION

#import <UIKit/UIKit.h>

Expand Down
3 changes: 0 additions & 3 deletions GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <TargetConditionals.h>

#import "GIDConfiguration.h"
#import "GIDGoogleUser.h"
#import "GIDProfileData.h"
#import "GIDSignIn.h"
#import "GIDToken.h"
#import "GIDSignInResult.h"
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
#import "GIDSignInButton.h"
#endif
4 changes: 2 additions & 2 deletions GoogleSignIn/Tests/Unit/GIDConfigurationTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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
Loading
Loading