我在尝试运行 XCTests 时遇到多个函数错误。
例如,我有一个简单的数组扩展来提取唯一的数组:
public extension CollectionType where Generator.Element: Hashable {
/// Returns the collection with duplicate values in `self` removed.
var unique: [Generator.Element] {
get {
var seen: [Generator.Element:Bool] = [:]
return self.filter { (element) -> Bool in
return seen.updateValue(true, forKey: element) == nil
}
}
}
}
但是在测试中,当我尝试使用它时遇到错误:
Ambiguous use of 'unique'
有什么解决办法吗?
最佳答案
我发现我的问题是我的 swift 文件包含在我的框架目标和 XCTest 目标中(因此编译器看到该文件包含了两次,导致了歧义)。从测试目标中删除它修复了错误。希望这对其他人(或 future 的我)有所帮助。
关于arrays - 运行 XCTests 时出现 "Ambiguous use of ' MYFUNCTION( )'"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34726595/