OhNoNotALinkerError
OhNoNotALinkerError

Reputation: 323

iOS AWS protocol methods with Error type as parameter causes protocol to not conform

I am using AWS Mobile Hub to implement login for my iOS app written in Swift. Up until this week, it was working perfectly, but updating to Xcode 9.1 caused several build errors to occur. I have 2 errors remaining. Both involve calls specifically to protocols; 'AWSSignInDelegate' and 'AWSCognitoIdentityPasswordAuthentication'.

extension SignInVC: AWSSignInDelegate
{
   func onLogin(signInProvider: AWSSignInProvider, result: Any?, error: Error?)
   {
      //Code
   }
}

extension SignInVC: AWSCognitoIdentityPasswordAuthentication
{
   func getDetails(_ authenticationInput: AWSCognitoIdentityPasswordAuthenticationInput, passwordAuthenticationCompletionSource: AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails>)
   {
      //Code
   }

   func didCompleteStepWithError(_ error: Error?)
   {
      //Code
   }
}

Errors:

Type 'SignInVC' does not conform to protocol 'AWSSignInDelegate'

Candidate has non-matching type '(AWSSignInProvider, Any?, Error?) -> ()'

and

Type 'SignInVC' does not conform to protocol 'AWSCognitoIdentityPasswordAuthentication'

Candidate has non-matching type '(Error?) -> ()'

What I have so far: The errors only occur to methods that include the swift type "Error" as a parameter. The 'getDetails' call above appears to not throw an error like the other 2 methods do.

A similar question here: Cannot conform to STPAddCardViewControllerDelegate since Xcode 8 GM on Swift 3

proposes adding @escaping to a completion block to fix a similar error. My problem doesn't involve a completion block though. So I assume I am incorrectly handling the swift Error type as a parameter, seeing as the implementation of these 2 methods in objc use NSError.

Any suggestions on how to fix this? Thanks so much!

Upvotes: 2

Views: 253

Answers (2)

OhNoNotALinkerError
OhNoNotALinkerError

Reputation: 323

I found that the standard Swift Error type was being over written by a poorly named Error class somewhere else in my project.

Upvotes: 1

C1FR1
C1FR1

Reputation: 133

I am not very familiar with AWS, but I glanced at the documentation for the protocols you are using and the function names don't quite match up, look here for the names that I would assume are the most recent.

http://docs.aws.amazon.com/AWSiOSSDK/latest/Protocols/AWSCognitoIdentityPasswordAuthentication.html

http://docs.aws.amazon.com/AWSiOSSDK/latest/Protocols/AWSSignInDelegate.html

Upvotes: 0

Related Questions