我可以使用CMake为XCode(OCUnit)创建iOS单元测试目标吗? [英] Can I create an iOS unit test target for XCode (OCUnit) with CMake?

查看:118
本文介绍了我可以使用CMake为XCode(OCUnit)创建iOS单元测试目标吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用CMake为我的静态库和应用程序目标创建我的iOS xcode项目。现在也想从CMake创建单元测试目标,但尚未找到有关CMake是否支持此目标或如何创建octest目标的任何资源。

I currently use CMake to create my iOS xcode project, for both my static libs and application target. Now would like to create the unit test target from CMake as well, but haven't found any resources on whether CMake supports this or how to create the octest target.

可以我是从CMake创建的吗?如果是这样,您能解释一下吗?

Can I create this from CMake? If so, could you explain how?

推荐答案

否,CMake不支持iOS上的单元测试。另外,您不能在iOS上运行单独的可执行文件。

No, CMake doesn't support unit tests on iOS. Also you can not run separate executables on iOS.

其中一种解决方案是将单元测试编译为静态库而不是可执行文件,然后将其链接到XCTests或OCTests。您可以通过为 main 函数创建别名并隐藏所有其他符号来使用链接器做一些魔术。

One of the solutions could be compiling your unit tests into a static library instead of executable and then link them to your XCTests or OCTests. You can do some magic with linker by creating alias for the main function and hiding all the other symbols.

全部您必须自己实现的测试属性。

All the test properties you would have to implement yourself.

这篇关于我可以使用CMake为XCode(OCUnit)创建iOS单元测试目标吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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