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

后端 未结 11 1473
灰色年华
灰色年华 2020-12-20 10:52

I am using Alamofire for network handling in swift and run into one weird error. It seems like we can\'t pass Method enum as parameter.
[Error is on Method para

相关标签:
11条回答
  • 2020-12-20 11:14

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

    0 讨论(0)
  • 2020-12-20 11:14

    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 {

    }

    0 讨论(0)
  • 2020-12-20 11:17

    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.

    0 讨论(0)
  • 2020-12-20 11:18

    Had this error conflict when using "Moya" and when bridging a c framework, fixed it by implicitly adding Moya.Method module.

    var method: Moya.Method  {
        switch self {
           case .login: return .post
           case .register: return .post
        }
    }
    
    0 讨论(0)
  • 2020-12-20 11:21

    I managed to fix the problem by deleting the Alamofire folder in the pods project manually. Then, I do a "pod install" to reinstall the missing pods.

    There are significantly less files in the Alamofire folder after doing this.

    0 讨论(0)
  • 2020-12-20 11:24

    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, ...
    
    0 讨论(0)
提交回复
热议问题