I'm following an example and the author uses a type annotation on an associatedType however Xcode is throwing the error "cannont find type * in scope". There aren't any Cocoapods or thirdparty frameworks being used. Also I have tried to build the project but it doesn't compile.
Here is the type which is in a separate Swift file:
import Foundation
protocol EndPointType {
var baseURL: URL {get}
var path: String {get}
var httpMethod: HTTPMethod {get}
var task: HTTPTask {get}
var headers: HTTPHeaders? {get}
}
And this is the code from another Swift file which has the associatedType attempting to use a type annotation:
import Foundation
public typealias NetworkRouterCompletion = (_ data: Data?,_ _response: URLResponse?, _ error: Error?)->()
protocol NetworkRouter: class {
associatedtype EndPoint: EndPointType
func request(_ route: EndPoint, completion: @escaping NetworkRouterCompletion)
func cancel()
}
Why wouldn't the second Swift file see the data type in order to compile?
I moved the Swift file into a subgroup and Xcode thought I deleted the file but it was in the workspace. I moved the Swift file back into the subgroup and the problem went away.