0Day Forums
'Method' is ambiguous for type lookup in this context, Error in Alamofire - Printable Version

+- 0Day Forums (https://0day.red)
+-- Forum: Coding (https://0day.red/Forum-Coding)
+--- Forum: Swift (https://0day.red/Forum-Swift)
+--- Thread: 'Method' is ambiguous for type lookup in this context, Error in Alamofire (/Thread-39-Method-39-is-ambiguous-for-type-lookup-in-this-context-Error-in-Alamofire)

Pages: 1 2


'Method' is ambiguous for type lookup in this context, Error in Alamofire - zincified126321 - 07-18-2023

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

[![enter image description here][1]][1]

private func apiRequest(method: Method, url: String, apiData: [String : AnyObject], completion:(finished: Bool, response: AnyObject?) ->Void) {

Alamofire.request(method, url, parameters: apiData).responseJSON{ response in
if let JSON = response.result.value {
completion(finished: true, response: JSON)
} else {
completion(finished: false, response:nil)
}
}
}


[1]:



RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - Prospirosayxxj - 07-18-2023

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.


RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - viator23 - 07-18-2023

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
}
}


RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - echiuroid546360 - 07-18-2023

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


RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - batfowling641595 - 07-18-2023

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 {

}


RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - Mrmoslemism6 - 07-18-2023

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.



RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - miguelk - 07-18-2023

**Swift 4 and Alamofire 4.7**

Replace `HTTPMethod` to `Alamofire.HTTPMethod`


RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - Sirdailesd - 07-18-2023

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 }
}




RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - blattering477421 - 07-18-2023

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.


RE: 'Method' is ambiguous for type lookup in this context, Error in Alamofire - sompay565026 - 07-18-2023

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.