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 }} 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 1a1ee63a0..c1713c1af 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 @@ -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:"); @@ -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 diff --git a/Sources/AppAuth/iOS/OIDAuthState+IOS.m b/Sources/AppAuth/iOS/OIDAuthState+IOS.m index c474a77d1..d0c3c31a3 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" @@ -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 @@ -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.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..ccf3ec1d8 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" @@ -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 @@ -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/OIDExternalUserAgentCatalyst.h b/Sources/AppAuth/iOS/OIDExternalUserAgentCatalyst.h index 910d0bb86..ef4a4beac 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 @@ -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 d6771b3e9..920a5db1c 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" @@ -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 diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.h index 12abc203c..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 +#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)) diff --git a/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m b/Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m index 4a8cda0a3..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 +#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 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