From b01d60a8538e9ef1e56dd8024b0b0daf735c73c2 Mon Sep 17 00:00:00 2001 From: Worthing ~ <115107835+w-goog@users.noreply.github.com> Date: Fri, 7 Aug 2026 17:17:38 -0700 Subject: [PATCH 1/2] g-orchestrated: require resumeExternalUserAgentFlowWithURL:error: --- CHANGELOG.md | 3 ++- .../Source/AppDelegate.swift | 2 +- .../Example-iOS_Swift-SPM/Example/AppDelegate.swift | 2 +- README.md | 2 +- Sources/AppAuthCore/OIDExternalUserAgentSession.h | 11 +++++------ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82a5e312b..e79f0cb22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # UNRELEASED -- Add Swift name to `resumeExternalUserAgentFlowWithURL:error:` and update hint. (#966) +- BREAKING: `resumeExternalUserAgentFlowWithURL:error:` is now required in `OIDExternalUserAgentSession` to fix a Swift compiler crash (no workaround) caused by its `@optional` status with `NSError **`. Implementers must now provide this method. Affects projects since 2.1.0. ([#955](https://github.com/openid/AppAuth-iOS/pull/955)) +- Swift callers now spell the method `resumeExternalUserAgentFlow(_:)`. Since the method is no longer optional, you don't need optional-chaining anymore. For those migrating from 2.1.0, replace `try session.resumeExternalUserAgentFlow?(with: url)` with `try session.resumeExternalUserAgentFlow(url)`. Objective-C callers are unaffected. ([#966](https://github.com/openid/AppAuth-iOS/pull/966)) - Replace case range with explicit case labels in OIDTokenUtilities. Addresses issue #947. ([#963](https://github.com/openid/AppAuth-iOS/pull/963)) # 2.1.0 diff --git a/Examples/Example-iOS_Swift-Carthage/Source/AppDelegate.swift b/Examples/Example-iOS_Swift-Carthage/Source/AppDelegate.swift index 8e623d2f4..3089dc1b0 100644 --- a/Examples/Example-iOS_Swift-Carthage/Source/AppDelegate.swift +++ b/Examples/Example-iOS_Swift-Carthage/Source/AppDelegate.swift @@ -37,7 +37,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // such as no pending flow, which previously surfaced as an NSException. if let authorizationFlow = self.currentAuthorizationFlow { do { - try authorizationFlow.resumeExternalUserAgentFlow?(with: url) + try authorizationFlow.resumeExternalUserAgentFlow(url) self.currentAuthorizationFlow = nil return true } catch { diff --git a/Examples/Example-iOS_Swift-SPM/Example/AppDelegate.swift b/Examples/Example-iOS_Swift-SPM/Example/AppDelegate.swift index ff1f50e2a..4b047bf91 100644 --- a/Examples/Example-iOS_Swift-SPM/Example/AppDelegate.swift +++ b/Examples/Example-iOS_Swift-SPM/Example/AppDelegate.swift @@ -29,7 +29,7 @@ class AppDelegate: NSObject, UIApplicationDelegate { // such as no pending flow, which previously surfaced as an NSException. if let authorizationFlow = self.currentAuthorizationFlow { do { - try authorizationFlow.resumeExternalUserAgentFlow?(url) + try authorizationFlow.resumeExternalUserAgentFlow(url) self.currentAuthorizationFlow = nil return true } catch { diff --git a/README.md b/README.md index edbd54632..20748f40e 100644 --- a/README.md +++ b/README.md @@ -410,7 +410,7 @@ func application(_ app: UIApplication, // mismatches (OIDErrorCodeURLMismatch) are kept silent. if let authorizationFlow = self.currentAuthorizationFlow { do { - try authorizationFlow.resumeExternalUserAgentFlow(with: url) + try authorizationFlow.resumeExternalUserAgentFlow(url) self.currentAuthorizationFlow = nil return true } catch let error as NSError where error.code == OIDErrorCodeInvalidAuthorizationFlow.rawValue { diff --git a/Sources/AppAuthCore/OIDExternalUserAgentSession.h b/Sources/AppAuthCore/OIDExternalUserAgentSession.h index 8e92393f4..322cad4e0 100644 --- a/Sources/AppAuthCore/OIDExternalUserAgentSession.h +++ b/Sources/AppAuthCore/OIDExternalUserAgentSession.h @@ -55,19 +55,19 @@ NS_ASSUME_NONNULL_BEGIN __deprecated_msg("Use resumeExternalUserAgentFlowWithURL:error: instead. " "Swift: Use the throwing resumeExternalUserAgentFlow(_:)"); -@optional /*! @brief Clients should call this method with the result of the external user-agent code flow if it becomes available. This is the preferred replacement for the deprecated version. @param URL The redirect URL invoked by the server. @param error On failure, an NSError describing why the URL was not handled. Pass NULL if you do not need the error. - @discussion When the URL represented a valid response, implementations should clean up any - left-over UI state from the request, for example by closing the - \SFSafariViewController or loopback HTTP listener if those were used. The completion block - of the pending request should then be invoked. + @discussion Conforming types are required to implement this method. When the URL represented a + valid response, implementations should clean up any left-over UI state from the request, for + example by closing the \SFSafariViewController or loopback HTTP listener if those were used. + The completion block of the pending request should then be invoked. Two specific error cases: (1) OIDErrorCodeURLMismatch when the URL does not match the expected redirect, (2) OIDErrorCodeInvalidAuthorizationFlow when no pending authorization flow exists. + This method was optional when introduced in 2.1.0. @remarks Has no effect if called more than once, or after a @c cancel message was received. @return YES if the passed URL matches the expected redirect URL and was consumed. NO if the URL did not match (\@c OIDErrorCodeURLMismatch) or no authorization flow @@ -75,7 +75,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (BOOL)resumeExternalUserAgentFlowWithURL:(NSURL *)URL error:(NSError *_Nullable *_Nullable)error NS_SWIFT_NAME(resumeExternalUserAgentFlow(_:)); -@required /*! @brief @c OIDExternalUserAgent or clients should call this method when the external user-agent flow failed with a non-OAuth error. @param error The error that is the reason for the failure of this external flow. From 33383f0ad12dd4d1b25b27f22ee8df87a867783b Mon Sep 17 00:00:00 2001 From: Worthing ~ <115107835+w-goog@users.noreply.github.com> Date: Fri, 7 Aug 2026 18:09:15 -0700 Subject: [PATCH 2/2] Remove note about 2.1.0 optionality --- Sources/AppAuthCore/OIDExternalUserAgentSession.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/AppAuthCore/OIDExternalUserAgentSession.h b/Sources/AppAuthCore/OIDExternalUserAgentSession.h index 322cad4e0..7a62b4e22 100644 --- a/Sources/AppAuthCore/OIDExternalUserAgentSession.h +++ b/Sources/AppAuthCore/OIDExternalUserAgentSession.h @@ -67,7 +67,6 @@ NS_ASSUME_NONNULL_BEGIN Two specific error cases: (1) OIDErrorCodeURLMismatch when the URL does not match the expected redirect, (2) OIDErrorCodeInvalidAuthorizationFlow when no pending authorization flow exists. - This method was optional when introduced in 2.1.0. @remarks Has no effect if called more than once, or after a @c cancel message was received. @return YES if the passed URL matches the expected redirect URL and was consumed. NO if the URL did not match (\@c OIDErrorCodeURLMismatch) or no authorization flow