Method' is ambiguous for type lookup in this context, Error in Alamofire
You have to specify the module from which to lookup object type.
Call Alamofire.Method
Xcode 8 beta 'Error' is ambiguous for type lookup in this context
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 :)
Promise' is ambiguous for type lookup in this context
I solved this problem by changing my return type to Promises.Promise .
Object' is ambiguous for type lookup in this context in Xcode 9
In my case, I had this ambiguity because the class was declared in a swift file and also being auto-generated by my data model.
If you already declare your class in a swift file, then make sure the code generation is disabled for it.
- Select your entity in your xcdatamodeld
- Open the third tab, Data Model inspector:
- Set Codegen to Manual/None
CompletionHandler' is ambiguous for type lookup in this context
Change
extension NetworkClientType {
typealias CompletionHandler = (Data?, URLResponse?, Error?) -> Void
to
extension NetworkClientType
where CompletionHandler == (Data?, URLResponse?, Error?) -> Void {
JSONEncoder' / 'JSONDecoder' is ambiguous for type lookup in this context
The JSONCodable
also declares the JSONEncoder
/JSONDecoder
classes, so the compiler doesn't know which ones you want extend: the standard ones, or the ones from the library.
Telling to the compiler which class to extend by prefixing the class with the module name, should eliminate the ambiguity.
import Foundation
import JSONCodable
extension JSONCodable.JSONEncoder {
// extension code
}
extension JSONCodable.JSONDecoder {
// extension code
}
However that won't work for this particular library, as the library declares a protocol with the same name (JSONCodable
). Thus, you need to explicitly import only the two classes from the module (see this SO post for more details):
import Foundation
import class JSONCodable.JSONEncoder
import class JSONCodable.JSONDecoder
extension JSONCodable.JSONEncoder {
// your code
}
extension JSONCodable.JSONDecoder {
// your code
}
Couldn't lookup symbols error using Alamofire in Playgrounds
Try adding this to your Podfile
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CONFIGURATION_BUILD_DIR'] = '$PODS_CONFIGURATION_BUILD_DIR'
end
end
end
Make sure to run pod install again to regenerate the Pods project. Then clean the build with Command-Shift-K
, rebuild it with Command-B
, and run your playground. The error should disappear.
Source: https://learnappmaking.com/cocoapods-playground-how-to/
How do I resolve this ambiguous type error in Swift?
If you directly import the Result module's Result
type, it'll override Alamofire's Result
type. You can still reach Alamofire's using its qualified name:
import Alamofire
import enum Result.Result
let a: Alamofire.Result<T, ErrorType> // Alamofire's Result
let r: Result<T, ErrorType> // Result module's Result
I found this out through trial and error after seeing detailed import mentioned in the language reference. I don't know if type name resolution is documented anywhere as working this way, so it might change without much notice.
Related Topics
How to Add an Optional String Extension
How to Set Addobserver in Swiftui
How to Use Raycast Methods in Realitykit
Convert String to Bool in Swift - via API or Most Swift-Like Approach
How to Make a Swift Enum with Uicolor Value
Initializer for Conditional Binding Must Have Optional Type, Not 'String'
How to Create Nsradiobutton Group in Xcode 7 Osx
How to Create a Window with Transparent Background with Swift on Osx
How Does Dictionary Use the Equatable Protocol in Swift
Cast a Swift Struct to Unsafemutablepointer<Void>
Checking If a Value Is Changed Using Kvo in Swift 3
Swift Dictionary: Remove Time Complexity
Scene Size in Xcode 6/Spritekit/Swift
How to Find Actual Swiftui API Documentation (And Not Just the Developer Documentation)
Swift - UI Button Shadow Gradient
Protocol Extending Encodable (Or Codable) Does Not Conform to It