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

2

11

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

Demilitarize answered 8/9, 2016 at 15:9 Comment(11)
Can you post the entire contents of this file, including your import statements? There's a good chance multiple imported modules provide an Error type, and you need to be specific about which one you want. Also, maybe the type signature has changed in iOS 10, but prior versions of this method used NSError, not Error.Uniseptate
Xcode 8 GM it is already available for downloadSunglass
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error)Sunglass
Why is your method @nonobjc? That'll just conceal it from Objective-C, and therefore won't be called by the app delegate.Krystenkrystin
@CraigOtis thx for the response , I just add some infos to my questionDemilitarize
Import Statement it is not the issueSunglass
@Krystenkrystin it was just a warning before add @nonobjc , but xcode wants me avoid this warning after add thisDemilitarize
@LeoDabus thx for notice , I am now downloading ..Demilitarize
even without @nonobjc , error still appear , it just avoid the warning show upDemilitarize
One of the modules you're importing has most likely defined its own Error type – you could use Swift.Error to disambiguateKrystenkrystin
@Krystenkrystin , mark my import module Realm and RealmSwift solve this problem ! ThxDemilitarize
O
24

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 :)

Omen answered 28/9, 2016 at 17:0 Comment(1)
Thanks for the response ! After Update to xcode 8 GM solved the problemDemilitarize
A
7

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.

Akers answered 28/5, 2017 at 16:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.