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

旧巷老猫 提交于 2019-11-29 13:06:53
harpreetSingh

You have to specify the module from which to lookup object type. Call Alamofire.Method

There is probably a name collision. To solve it, you can use the qualified name of the enum (including the module name):

private func apiRequest(method: Alamofire.Method, ...

I have also encountered this problem, because I have declared a number of the same name of the protocol:

protocol SomeProtocol {
   static func someTypeMethod()
}

protocol SomeProtocol {
   init(someParameter: Int)
}

protocol SomeProtocol {
   var mustBeSettable: Int { get set }
   var doesNotNeedToBeSettable: Int { get }
}

You may have a class declared in two or more places in your application. The error is saying that there is no conclusive way to use this class because there are a couple different places in the code it is declared.

Swift 4 and Alamofire 4.7

Replace HTTPMethod to Alamofire.HTTPMethod

While the answer to this did fix the build error; in my case, the file showing the warning was in two different frameworks so Xcode did not know where to look. This was not the intended behavior of our internal frameworks so I simply removed the copy I no longer wanted.

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

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

typealias Method = Alamofire.Method

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

Change the enum type name to different &...

  • Use the $(inherited) flag, or
  • Remove the build settings from the target.

Target - > building settings- >ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES, Value type is Boolean, click on the other, change the value to $(inherited) perform - pod update Done

then try to run Your project , error will gone ! (I have tried in my project)

enum 'XYZ'ButtonType {

}

I got this error because my database table name and model class name was same...Issue resolved by renaming model class name.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!