Xcode 8 beta 'Error' is ambiguous for type lookup in this context

9.7k Views Asked by At

According to this article, I need to specify the module to lookup object type:

'Method' is ambiguous for type lookup in this context, Error in Alamofire

But the below function is call from Apple API. Should I wait until Xcode 8 is out of beta? Or am I missing anything?

'Error' is ambiguous for type lookup in this context

function in AppDelegate.swift

enter image description here

Import section

enter image description here

2

There are 2 best solutions below

1
BilalReffas On BEST ANSWER

The Solution is to just type Swift.Error instead of Error.

The issue occurs when one of your modules has its own Error Type...:/

For example:

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Swift.Error) {}

I hope this works for you :)

0
Marián Černý On

The type Error is declared in two imported modules. You have to specify the module from which to use the type. Use Swift.Method instead of Method.

Tip: If you are using the type often, you can create a type alias in your module (application):

typealias Error = Swift.Error

That way you will not need to prefix the type with Swift. any more.