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 #858

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 19 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
"-scheme AppAuthTV -destination 'platform=tvOS Simulator,name=Apple TV,OS=16.1' -sdk 'appletvsimulator16.1'"
]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run unit test targets
run: |
xcodebuild test \
Expand All @@ -41,7 +41,7 @@ jobs:
'--use-static-frameworks'
]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Bundler
run: bundle update --bundler
- name: Install Ruby gems with Bundler
Expand All @@ -52,10 +52,26 @@ jobs:
spm-build-test:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build unit test target
run: swift build
- name: Run unit test target
run: swift test --enable-code-coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2

spm-test:
runs-on: macos-14
strategy:
matrix:
flags: [
"-destination 'platform=iOS Simulator,name=iPhone 11,OS=16.2' -sdk 'iphonesimulator16.2'",
"-destination 'platform=visionOS simulator,name=Any visionOS Simulator Device' -sdk xrsimulator",
"-sdk macos",
]
steps:
- uses: actions/checkout@v4
- name: Remove xcodeproj to test Package.swift
run: rm -rf AppAuth.xcodeproj
- name: Run unit test targets
run: xcodebuild -scheme AppAuth-Package test ${{ matrix.flags }}
2 changes: 1 addition & 1 deletion Sources/AppAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#if TARGET_OS_TV
#elif TARGET_OS_WATCH
#elif TARGET_OS_IOS || TARGET_OS_MACCATALYST
#elif TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
#import "OIDAuthState+IOS.h"
#import "OIDAuthorizationService+IOS.h"
#import "OIDExternalUserAgentIOS.h"
Expand Down
6 changes: 3 additions & 3 deletions Sources/AppAuth/iOS/OIDAuthState+IOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 Expand Up @@ -73,12 +73,12 @@ NS_ASSUME_NONNULL_BEGIN

+ (id<OIDExternalUserAgentSession>)
authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest
callback:(OIDAuthStateAuthorizationCallback)callback API_AVAILABLE(ios(11)) API_UNAVAILABLE(macCatalyst)
callback:(OIDAuthStateAuthorizationCallback)callback API_AVAILABLE(ios(11)) API_UNAVAILABLE(macCatalyst) API_UNAVAILABLE(visionos)
__deprecated_msg("This method will not work on iOS 13. Use "
"authStateByPresentingAuthorizationRequest:presentingViewController:callback:");

@end

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 Sources/AppAuth/iOS/OIDAuthState+IOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#import <TargetConditionals.h>

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

#import "OIDAuthState+IOS.h"
#import "OIDExternalUserAgentIOS.h"
Expand All @@ -31,7 +31,7 @@ @implementation OIDAuthState (IOS)
presentingViewController:(UIViewController *)presentingViewController
callback:(OIDAuthStateAuthorizationCallback)callback {
id<OIDExternalUserAgent> externalUserAgent;
#if TARGET_OS_MACCATALYST
#if TARGET_OS_MACCATALYST || TARGET_OS_VISION
externalUserAgent = [[OIDExternalUserAgentCatalyst alloc]
initWithPresentingViewController:presentingViewController];
#else // TARGET_OS_MACCATALYST
Expand All @@ -48,7 +48,7 @@ @implementation OIDAuthState (IOS)
prefersEphemeralSession:(BOOL)prefersEphemeralSession
callback:(OIDAuthStateAuthorizationCallback)callback {
id<OIDExternalUserAgent> externalUserAgent;
#if TARGET_OS_MACCATALYST
#if TARGET_OS_MACCATALYST || TARGET_OS_VISION
externalUserAgent = [[OIDExternalUserAgentCatalyst alloc]
initWithPresentingViewController:presentingViewController
prefersEphemeralSession:prefersEphemeralSession];
Expand All @@ -62,7 +62,7 @@ @implementation OIDAuthState (IOS)
callback:callback];
}

#if !TARGET_OS_MACCATALYST
#if !TARGET_OS_MACCATALYST && !TARGET_OS_VISION
+ (id<OIDExternalUserAgentSession>)
authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest
callback:(OIDAuthStateAuthorizationCallback)callback {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppAuth/iOS/OIDAuthorizationService+IOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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
6 changes: 3 additions & 3 deletions Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#import <TargetConditionals.h>

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

#import "OIDAuthorizationService+IOS.h"
#import "OIDExternalUserAgentIOS.h"
Expand All @@ -32,7 +32,7 @@ @implementation OIDAuthorizationService (IOS)
presentingViewController:(UIViewController *)presentingViewController
callback:(OIDAuthorizationCallback)callback {
id<OIDExternalUserAgent> externalUserAgent;
#if TARGET_OS_MACCATALYST
#if TARGET_OS_MACCATALYST || TARGET_OS_VISION
externalUserAgent = [[OIDExternalUserAgentCatalyst alloc]
initWithPresentingViewController:presentingViewController];
#else // TARGET_OS_MACCATALYST
Expand All @@ -46,7 +46,7 @@ @implementation OIDAuthorizationService (IOS)
prefersEphemeralSession:(BOOL)prefersEphemeralSession
callback:(OIDAuthorizationCallback)callback {
id<OIDExternalUserAgent> externalUserAgent;
#if TARGET_OS_MACCATALYST
#if TARGET_OS_MACCATALYST || TARGET_OS_VISION
externalUserAgent = [[OIDExternalUserAgentCatalyst alloc]
initWithPresentingViewController:presentingViewController
prefersEphemeralSession:prefersEphemeralSession];
Expand Down
4 changes: 2 additions & 2 deletions Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 All @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
/*! @brief A Catalyst specific external user-agent that uses `ASWebAuthenticationSession` to
present the request.
*/
API_AVAILABLE(macCatalyst(13)) API_UNAVAILABLE(ios)
API_AVAILABLE(macCatalyst(13), visionos(1)) API_UNAVAILABLE(ios)
@interface OIDExternalUserAgentCatalyst : NSObject<OIDExternalUserAgent>

/*! @internal
Expand Down
8 changes: 4 additions & 4 deletions Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#import <TargetConditionals.h>

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

#import "OIDExternalUserAgentCatalyst.h"

Expand All @@ -29,7 +29,7 @@
#import "OIDExternalUserAgentSession.h"
#import "OIDExternalUserAgentRequest.h"

#if TARGET_OS_MACCATALYST
#if TARGET_OS_MACCATALYST || TARGET_OS_VISION

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -152,6 +152,6 @@ - (ASPresentationAnchor)presentationAnchorForWebAuthenticationSession:(ASWebAuth

NS_ASSUME_NONNULL_END

#endif // TARGET_OS_MACCATALYST
#endif // TARGET_OS_MACCATALYST || TARGET_OS_VISION

#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION
3 changes: 1 addition & 2 deletions Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#import <TargetConditionals.h>

#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
#if TARGET_OS_IOS

#import <UIKit/UIKit.h>

Expand All @@ -31,7 +31,6 @@ NS_ASSUME_NONNULL_BEGIN
/*! @brief An iOS specific external user-agent that uses the best possible user-agent available
depending on the version of iOS to present the request.
*/
API_UNAVAILABLE(macCatalyst)
@interface OIDExternalUserAgentIOS : NSObject<OIDExternalUserAgent>

- (null_unspecified instancetype)init API_AVAILABLE(ios(11))
Expand Down
6 changes: 1 addition & 5 deletions Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#import <TargetConditionals.h>

#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
#if TARGET_OS_IOS

#import "OIDExternalUserAgentIOS.h"

Expand All @@ -29,8 +29,6 @@
#import "OIDExternalUserAgentSession.h"
#import "OIDExternalUserAgentRequest.h"

#if !TARGET_OS_MACCATALYST

NS_ASSUME_NONNULL_BEGIN

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
Expand Down Expand Up @@ -263,6 +261,4 @@ - (ASPresentationAnchor)presentationAnchorForWebAuthenticationSession:(ASWebAuth

NS_ASSUME_NONNULL_END

#endif // !TARGET_OS_MACCATALYST

#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
2 changes: 1 addition & 1 deletion Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#import <TargetConditionals.h>

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

#import <Foundation/Foundation.h>

Expand Down
18 changes: 15 additions & 3 deletions Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#import <TargetConditionals.h>

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

#import "OIDExternalUserAgentIOSCustomBrowser.h"

Expand Down Expand Up @@ -145,16 +145,28 @@ - (BOOL)presentExternalUserAgentRequest:(nonnull id<OIDExternalUserAgentRequest>
NSString *testURLString = [NSString stringWithFormat:@"%@://example.com", _canOpenURLScheme];
NSURL *testURL = [NSURL URLWithString:testURLString];
if (![[UIApplication sharedApplication] canOpenURL:testURL]) {
#if TARGET_OS_VISION
[[UIApplication sharedApplication] openURL:_appStoreURL options:@{} completionHandler:NULL];
#else
[[UIApplication sharedApplication] openURL:_appStoreURL];
#endif
return NO;
}
}

// Transforms the request URL and opens it.
NSURL *requestURL = [request externalUserAgentRequestURL];
requestURL = _URLTransformation(requestURL);
BOOL openedInBrowser = [[UIApplication sharedApplication] openURL:requestURL];
return openedInBrowser;
#if TARGET_OS_VISION
if ([[UIApplication sharedApplication] canOpenURL:requestURL]) {
[[UIApplication sharedApplication] openURL:requestURL options:@{} completionHandler:NULL];
return YES;
} else {
return NO;
}
#else
return [[UIApplication sharedApplication] openURL:requestURL];
#endif
}

- (void)dismissExternalUserAgentAnimated:(BOOL)animated
Expand Down