Issues implementing ASWebAuthenticationPresentationContextProviding with Xcode 14

Trying to implement a type that conforms to ASWebAuthenticationPresentationContextProviding. This is now causing errors with Xcode 14. With the following implementation:

        final class PresentationContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding {

            func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {

                return ASPresentationAnchor()

            }

        }

I get this compilation error:

Call to main actor-isolated initializer 'init()' in a synchronous nonisolated context

So I can annotate the class or method with @MainActor, but then I get this warning:

Main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Is there a way to fix this?

Accepted Reply

Nevermind. We had this class embedded in a function. Removing the definition out of that scope solved it.

Replies

Nevermind. We had this class embedded in a function. Removing the definition out of that scope solved it.

Actually, when building with strict-concurrency=complete and Xcode 14.3 I am seeing these errors again. ASPresentationAnchor() is MainActor, so it seems impossible to implement ASWebAuthenticationPresentationContextProviding and return a ASPresentationAnchor.

  • I'm having this issue too. Did you find a solution?

  • I have the same issue as well.

  • I have the same issue :)

Add a Comment