From e52173e270fcea0e28e886bdf205b468886a6439 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Thu, 9 May 2024 16:46:44 -0700 Subject: [PATCH 1/6] Build for visionOS --- Sources/AppAuth/iOS/OIDAuthState+IOS.h | 2 +- Sources/AppAuth/iOS/OIDAuthState+IOS.m | 2 +- .../AppAuth/iOS/OIDAuthorizationService+IOS.h | 2 +- .../AppAuth/iOS/OIDAuthorizationService+IOS.m | 2 +- .../AppAuth/iOS/OIDExternalUserAgentCatalyst.h | 2 +- .../AppAuth/iOS/OIDExternalUserAgentCatalyst.m | 2 +- Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h | 2 +- Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m | 2 +- .../iOS/OIDExternalUserAgentIOSCustomBrowser.h | 2 +- .../iOS/OIDExternalUserAgentIOSCustomBrowser.m | 18 +++++++++++++++--- 10 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Sources/AppAuth/iOS/OIDAuthState+IOS.h b/Sources/AppAuth/iOS/OIDAuthState+IOS.h index 1a1ee63a0..3def4e623 100644 --- a/Sources/AppAuth/iOS/OIDAuthState+IOS.h +++ b/Sources/AppAuth/iOS/OIDAuthState+IOS.h @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import diff --git a/Sources/AppAuth/iOS/OIDAuthState+IOS.m b/Sources/AppAuth/iOS/OIDAuthState+IOS.m index c474a77d1..dc47fab3e 100644 --- a/Sources/AppAuth/iOS/OIDAuthState+IOS.m +++ b/Sources/AppAuth/iOS/OIDAuthState+IOS.m @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import "OIDAuthState+IOS.h" #import "OIDExternalUserAgentIOS.h" diff --git a/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.h b/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.h index c7c685d28..6730931e2 100644 --- a/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.h +++ b/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.h @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import diff --git a/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m b/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m index 4ca07c55e..5ffa3af9d 100644 --- a/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m +++ b/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import "OIDAuthorizationService+IOS.h" #import "OIDExternalUserAgentIOS.h" diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h index 910d0bb86..592b12260 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m index d6771b3e9..9407dc8ab 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import "OIDExternalUserAgentCatalyst.h" diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h index 12abc203c..57ffe901b 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m index 4a8cda0a3..8c30fe8bb 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import "OIDExternalUserAgentIOS.h" diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.h b/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.h index 2032e8c91..581fe2a14 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.h +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.h @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m b/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m index be5dc820c..cf2792095 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION #import "OIDExternalUserAgentIOSCustomBrowser.h" @@ -145,7 +145,11 @@ - (BOOL)presentExternalUserAgentRequest:(nonnull id 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; } } @@ -153,8 +157,16 @@ - (BOOL)presentExternalUserAgentRequest:(nonnull id // 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 From c1b834c07832a444853b17c057f4377ab947cca1 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Thu, 9 May 2024 16:57:29 -0700 Subject: [PATCH 2/6] build fixes --- Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m index 8c30fe8bb..14f69d99d 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION +#if TARGET_OS_IOS #import "OIDExternalUserAgentIOS.h" @@ -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 @@ -263,6 +261,4 @@ - (ASPresentationAnchor)presentationAnchorForWebAuthenticationSession:(ASWebAuth NS_ASSUME_NONNULL_END -#endif // !TARGET_OS_MACCATALYST - #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST From 7dfa56a8f9a0ec5513c9ed833fc5f5c47b022d9c Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 10 May 2024 08:56:21 -0700 Subject: [PATCH 3/6] fixes --- Sources/AppAuth.h | 2 +- Sources/AppAuth/iOS/OIDAuthState+IOS.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/AppAuth.h b/Sources/AppAuth.h index 19abc55e1..c96630c63 100644 --- a/Sources/AppAuth.h +++ b/Sources/AppAuth.h @@ -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" diff --git a/Sources/AppAuth/iOS/OIDAuthState+IOS.h b/Sources/AppAuth/iOS/OIDAuthState+IOS.h index 3def4e623..433970324 100644 --- a/Sources/AppAuth/iOS/OIDAuthState+IOS.h +++ b/Sources/AppAuth/iOS/OIDAuthState+IOS.h @@ -81,4 +81,4 @@ NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END -#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION From a24fa54a542e39147d404764dddec8bfd6060559 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 10 May 2024 09:17:39 -0700 Subject: [PATCH 4/6] Use Catalyst OIDExternalUserAgentCatalyst for visionOS --- Sources/AppAuth/iOS/OIDAuthState+IOS.m | 2 +- Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m | 2 +- Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h | 2 +- Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/AppAuth/iOS/OIDAuthState+IOS.m b/Sources/AppAuth/iOS/OIDAuthState+IOS.m index dc47fab3e..8d3a154f6 100644 --- a/Sources/AppAuth/iOS/OIDAuthState+IOS.m +++ b/Sources/AppAuth/iOS/OIDAuthState+IOS.m @@ -31,7 +31,7 @@ @implementation OIDAuthState (IOS) presentingViewController:(UIViewController *)presentingViewController callback:(OIDAuthStateAuthorizationCallback)callback { id externalUserAgent; -#if TARGET_OS_MACCATALYST +#if TARGET_OS_MACCATALYST || TARGET_OS_VISION externalUserAgent = [[OIDExternalUserAgentCatalyst alloc] initWithPresentingViewController:presentingViewController]; #else // TARGET_OS_MACCATALYST diff --git a/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m b/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m index 5ffa3af9d..77bb73054 100644 --- a/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m +++ b/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m @@ -32,7 +32,7 @@ @implementation OIDAuthorizationService (IOS) presentingViewController:(UIViewController *)presentingViewController callback:(OIDAuthorizationCallback)callback { id externalUserAgent; -#if TARGET_OS_MACCATALYST +#if TARGET_OS_MACCATALYST || TARGET_OS_VISION externalUserAgent = [[OIDExternalUserAgentCatalyst alloc] initWithPresentingViewController:presentingViewController]; #else // TARGET_OS_MACCATALYST diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h index 592b12260..ef4a4beac 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h @@ -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 /*! @internal diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m index 9407dc8ab..920a5db1c 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.m @@ -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 @@ -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 From b866746b699fb9252fe0c5a743d4575ac2676f27 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 10 May 2024 09:32:49 -0700 Subject: [PATCH 5/6] fixes --- Sources/AppAuth/iOS/OIDAuthState+IOS.h | 2 +- Sources/AppAuth/iOS/OIDAuthState+IOS.m | 4 ++-- Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m | 2 +- Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Sources/AppAuth/iOS/OIDAuthState+IOS.h b/Sources/AppAuth/iOS/OIDAuthState+IOS.h index 433970324..c1713c1af 100644 --- a/Sources/AppAuth/iOS/OIDAuthState+IOS.h +++ b/Sources/AppAuth/iOS/OIDAuthState+IOS.h @@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN + (id) 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:"); diff --git a/Sources/AppAuth/iOS/OIDAuthState+IOS.m b/Sources/AppAuth/iOS/OIDAuthState+IOS.m index 8d3a154f6..d0c3c31a3 100644 --- a/Sources/AppAuth/iOS/OIDAuthState+IOS.m +++ b/Sources/AppAuth/iOS/OIDAuthState+IOS.m @@ -48,7 +48,7 @@ @implementation OIDAuthState (IOS) prefersEphemeralSession:(BOOL)prefersEphemeralSession callback:(OIDAuthStateAuthorizationCallback)callback { id externalUserAgent; -#if TARGET_OS_MACCATALYST +#if TARGET_OS_MACCATALYST || TARGET_OS_VISION externalUserAgent = [[OIDExternalUserAgentCatalyst alloc] initWithPresentingViewController:presentingViewController prefersEphemeralSession:prefersEphemeralSession]; @@ -62,7 +62,7 @@ @implementation OIDAuthState (IOS) callback:callback]; } -#if !TARGET_OS_MACCATALYST +#if !TARGET_OS_MACCATALYST && !TARGET_OS_VISION + (id) authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest callback:(OIDAuthStateAuthorizationCallback)callback { diff --git a/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m b/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m index 77bb73054..ccf3ec1d8 100644 --- a/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m +++ b/Sources/AppAuth/iOS/OIDAuthorizationService+IOS.m @@ -46,7 +46,7 @@ @implementation OIDAuthorizationService (IOS) prefersEphemeralSession:(BOOL)prefersEphemeralSession callback:(OIDAuthorizationCallback)callback { id externalUserAgent; -#if TARGET_OS_MACCATALYST +#if TARGET_OS_MACCATALYST || TARGET_OS_VISION externalUserAgent = [[OIDExternalUserAgentCatalyst alloc] initWithPresentingViewController:presentingViewController prefersEphemeralSession:prefersEphemeralSession]; diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h index 57ffe901b..cb8902a17 100644 --- a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h +++ b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h @@ -18,7 +18,7 @@ #import -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_VISION +#if TARGET_OS_IOS #import @@ -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 - (null_unspecified instancetype)init API_AVAILABLE(ios(11)) From 168ce6a14e71677eb3e4c0f4c578acc6e1d923ea Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Tue, 14 May 2024 10:38:39 -0700 Subject: [PATCH 6/6] update CI --- .github/workflows/tests.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 523bed57d..7b9dd9420 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 \ @@ -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 @@ -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 }}