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

2019-05-17  本文已影响0人  iamjjh
  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)
上一篇下一篇

猜你喜欢

热点阅读