是否可以使用XCode的SenTestingKit对静态库项目进行单元测试?

编程入门 行业动态 更新时间:2024-10-28 02:29:20
本文介绍了是否可以使用XCode的SenTestingKit对静态库项目进行单元测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经按照Apple文档中提供的步骤创建了一个iOS单元测试目标,用于进行逻辑测试。

I've created an iOS unit test target for doing logic tests following the steps provided in Apple's documentation.

但是我的构建失败,我收到以下错误:

However my build fails and i get the following error:

未定义的符号: _ OBJC_CLASS _ $ _ MyClass,引自:在LogicTests.o中的objc-class-ref-to-MyClass ld:符号不是被找到collect2:ld返回1退出状态

Undefined symbols: "_OBJC_CLASS_$_MyClass", referenced from: objc-class-ref-to-MyClass in LogicTests.o ld: symbol(s) not found collect2: ld returned 1 exit status

通常,如果我想在应用程序中使用我的静态库,我会包括library.a文件和标题(包括MyClass.h文件......)。如果我的测试用例使用MyClass.h,那么在同一项目的静态库上运行逻辑测试需要额外的东西吗?

Ordinarily, if I wanted to use my static library within an application I would include the library.a file, and the headers(including the MyClass.h file...). Is something additional required to run logic tests on a static library WITHIN that same project if my test cases are utilizing MyClass.h ?

Tjhanks

推荐答案

我其实只是解决了它。我不得不将项目中的所有.m文件复制到LogicTest目标的'Compile Sources'。除了添加框架,源代码引用目标的Link Binary With Libraries部分。

I actually just solved it. I had to copy all of the .m files in my project to the LogicTest target's 'Compile Sources'. As well as add the frameworks the sources reference to the 'Link Binary With Libraries' section of the target.

我希望这有助于其他人

更多推荐

是否可以使用XCode的SenTestingKit对静态库项目进行单元测试?

本文发布于:2023-11-14 16:17:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587931.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   静态   单元测试   项目   SenTestingKit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!