使用 Quick 和 Nimble 进行 Swift 单元测试

  1. 在单元测试的 Target -> General 勾选 Allow testing Host Application APIs
  2. 在 Podfile 中添加 Quick 和 Nimble
  3. 在 Podfile 中使用 use_frameworks! 或者 use_modular_headers! (单独指定:modular_headers => true也可以)

忘记勾选 Allow testing Host Application APIs,在 import 第三方库的时候会报以下错误:

Undefined symbols for architecture x86_64:
  "ObjectMapper.<- infix<A>(inout A, ObjectMapper.Map) -> ()", referenced from:
      DDBaseKitModule_Tests.TestModel.mapping(map: ObjectMapper.Map) -> () in DDModelTypeSpec.o
  "ObjectMapper.<- infix<A>(inout A?, ObjectMapper.Map) -> ()", referenced from:
      DDBaseKitModule_Tests.TestModel.mapping(map: ObjectMapper.Map) -> () in DDModelTypeSpec.o
  "(extension in DDBaseKitModule):Swift.Dictionary< where A == Swift.String>.queryStringParameters() -> Swift.String", referenced from:
      closure #1 () -> () in closure #1 () -> () in DDBaseKitModule_Tests.ExtensionSpec.spec() -> () in ExtensionSpec.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容