是否可以使用XCode的SenTestingKit对静态库项目进行单元测试? [英] Is it possible to unit test a static library project using XCode's SenTestingKit?

查看:103
本文介绍了是否可以使用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对静态库项目进行单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆