尝试将XCTest与Cordova项目集成时出现错误。它发生在新的cordova应用中,无需自定义。只需添加XCTest,测试就会失败,并显示以下错误:
Undefined symbols for architecture i386:
"_CGRectZero", referenced from:
+[CDVUserAgentUtil originalUserAgent] in libCordova.a(CDVUserAgentUtil.o)
"_OBJC_CLASS_$_ALAssetsLibrary", referenced from:
objc-class-ref in libCordova.a(CDVURLProtocol.o)
"_OBJC_CLASS_$_CLLocation", referenced from:
l_OBJC_$CATEGORY_CLLocation$_JSONMethods in libCordova.a(CDVShared.o)
"_UTTypeCopyPreferredTagWithClass", referenced from:
___30-[CDVURLProtocol startLoading]_block_invoke in libCordova.a(CDVURLProtocol.o)
"_kUTTagClassMIMEType", referenced from:
___30-[CDVURLProtocol startLoading]_block_invoke in libCordova.a(CDVURLProtocol.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我尝试删除i386架构无济于事,并提出了许多其他建议,但这是在逃避我。
有什么想法吗?提前致谢!
编辑:
我忘了注意到项目构建得很好,但是运行测试(通过产品->测试)会导致这些错误。
最佳答案
找到了。
您必须将每个框架添加到所需的测试目标。就我而言,我需要添加:
CoreLocation.framework
AssetsLibrary.framework
CoreGraphics.framework
MobileCoreServices.framework
之后,单元测试按预期失败。