未定义的架构符号x86_64用于使用 Alamofire.Request 进行扩展

Undefined symbols for architecture x86_64 for extension with an Alamofire.Request

提问人:Fang-Pen Lin 提问时间:2/17/2016 最后编辑:Fang-Pen Lin 更新时间:2/17/2016 访问量:688

问:

我为 创建了一个协议,然后像这样扩展它Alamofire.Response

import Alamofire
public protocol MyResponseType {
    typealias Value
    typealias Error: ErrorType
    var request: NSURLRequest? { get }
    var response: NSHTTPURLResponse? { get }
    var data: NSData? { get }
    var result: Alamofire.Result<Value, Error> { get }
    init(request: NSURLRequest?, response: NSHTTPURLResponse?, data: NSData?, result: Alamofire.Result<Value, Error>, timeline: Alamofire.Timeline)
}

extension Alamofire.Response: MyResponseType {}

构建过程通过了,但当涉及到链接时,它失败了。错误来了

Undefined symbols for architecture x86_64:
  "Alamofire.Response.data.getter : __ObjC.NSData?", referenced from:
      protocol witness for wtftest. MyResponseType.data.getter : __ObjC.NSData? in conformance <A, B where B: Swift.ErrorType> Alamofire.Response<A, B> : wtftest. MyResponseType in wtftest in ViewController.o
  "Alamofire.Response.result.getter : Alamofire.Result<A, B>", referenced from:
      protocol witness for wtftest. MyResponseType.result.getter : Alamofire.Result<A.Value, A.Error> in conformance <A, B where B: Swift.ErrorType> Alamofire.Response<A, B> : wtftest.ProducerResponseType in wtftest in ViewController.o
  "Alamofire.Response.request.getter : __ObjC.NSURLRequest?", referenced from:
      protocol witness for wtftest. MyResponseType.request.getter : __ObjC.NSURLRequest? in conformance <A, B where B: Swift.ErrorType> Alamofire.Response<A, B> : wtftest. MyResponseType in wtftest in ViewController.o
  "Alamofire.Response.response.getter : __ObjC.NSHTTPURLResponse?", referenced from:
      protocol witness for wtftest. MyResponseType.response.getter : __ObjC.NSHTTPURLResponse? in conformance <A, B where B: Swift.ErrorType> Alamofire.Response<A, B> : wtftest.ProducerResponseType in wtftest in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这是 swift 的错误吗?还是我做错了什么?

swift2 linker-errors alamofire

评论

0赞 Sohil R. Memon 2/17/2016
也请提及ProducerResponseType
0赞 Fang-Pen Lin 2/17/2016
@SohilR.Memon对不起,这里其实是MyResponseType,忘了修改,ProducerResponseType
0赞 quickthyme 4/7/2016
关于这一点,我也在用头撞墙。仅在以模拟器为目标时失败,但设备仍能正常工作。

答: 暂无答案