'Using AWS Amplify Auth with iOS Combine

I am trying to use AWS Amplify Auth with iOS Combine to integrate social network logins (Google, Facebook and Apple) but I blocked with:

func signInWithFacebook(context: Any) -> AnyPublisher<AuthSignInResult, AuthError> {
    guard let window = context as? UIWindow else {
        return Fail(error: AuthError(error: Foo.unexpectedError(reason: "empty context")))
                    .eraseToAnyPublisher()
    }
        
    return Amplify.Auth.signInWithWebUI(for: .facebook, presentationAnchor: window)
            .resultPublisher
            .eraseToAnyPublisher()
}

FooError is a basic enum

enum FooError: Error {
   case unexpectedError(reason: String)
}

However, I cannot seem to get the Fail construct correct, I am getting the following error: 'AuthSignInStep' cannot be constructed because it has no accessible initializers

Thoughts on how I can construct the Fail mechanism?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source