Xcode 4.2 代码覆盖率
我开始使用 Xcode 4.2,但在生成代码覆盖率方面遇到问题。
Xcode 4.2 不包含 GCC 4.2 编译器,但已替换为 LLVM GCC 4.2 编译器。 第一个用于在以前版本的 Xcode 中生成代码覆盖率。
我按照 CoverStory 网站 上的“教程”进行操作,但结果如下:
a)当我执行所有步骤时,没有覆盖文件。
b)当我将 libprofile_rt.dylib 链接到我的项目时,应该失败的测试不再失败。
有人遇到过这个问题吗?你是怎么解决的?
谢谢
I started to use Xcode 4.2 and i have problems with generating code coverage.
Xcode 4.2 does not include the GCC 4.2 compiler, but it was replaced with the LLVM GCC 4.2 compiler.
The first one was needed to generate code coverage in the previous version of Xcode.
I followed the 'tutorial' on CoverStory website, but this results in the following:
a) when i do all steps, no coverage files.
b) when i link the libprofile_rt.dylib to my project, the test which should fail, do not fail anymore.
Did anyone encounter this issue? And how did you solve it?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此博客有一个很好的有关如何使用 LLVM 实现与 gcc 兼容的覆盖率结果的教程。
当前 LLVM 前端中提供了覆盖功能,但它似乎并未公开
在 XCode 附带的当前版本中。
我同意作者的观点,它可以是编译您自己的版本以进行覆盖的解决方案
目的并坚持使用交付的版本来生成最终的二进制文件。
我还值得注意的是,他的教程声称:
也许这对你有用。
This Blog has a nice tutorial on how to achive gcc-compatible coverage results with LLVM.
The coverage features are available in the current LLVM frontend but as it seems not exposed
in the current version that ships with XCode.
I agree tho the author that it can be a solution to compile your own version for coverage
purposes and stick to the shipped version for final binary generation.
I's also worth to note that his tutorial claims:
Maybe this is of some use to you.
这是一种在 xcode 4.2 中启用 gcc 4.2 编译的方法。这主要是通过命令行完成的,因此当您看到以以下开头的行时:
[ 15:30 jon@MacBookPro / ]$
,您需要打开Terminal.app并运行在$
之后开始的命令。下载 - 但暂时不要安装 - xcode_4.1_for_lion.dmg 或 xcode_4.1_for_snow_leopard.dmg< /p>
/Developer-4.1
:备份工作
/Developer
目录(安装 Xcode 4.2 的位置)使用默认安装位置 (
/Developer
) 运行 Xcode 4.1 安装程序将新的 Xcode 4.1 安装移至
/Developer-4.1
:将 Xcode 4.2 开发人员目录移回
/Developer
:编辑 Xcode 4.2
GCC 4.2.xcspec
文件以获取 gcc 4.2在编译器选项列表中显示[1]:将 41 和 42 行从此更改:
致此:
备份 Xcode 4.2 iOS/Simulator Framework
usr
目录:将 Xcode 4.1 iOS/Simulator Framework
usr
目录复制到 Xcode 4.2:< /p>复制
gcc
和info
从 Xcode 4.1 到 Xcode 4.2 的 iOS SDK 库目录[2]:使用gcc-4.2编译!
这是一个我写的博客文章提供了有关此过程的更多信息。如果您遇到任何问题或有任何疑问,请随时在博客上发表评论。
[1] 如果从命令行打开(使用类似
vi
、emacs
、nano
等)确保将路径用引号括起来 "/long path/with space/in it/ file.xcspec" 或转义空格/some/long\ path/with\spaces/in\ it/file.xcspec[2] 这是必要的,因为 iPhoneOS.platform SDK 有自己的单独的
/usr/lib
目录,但 iPhoneSimulator.platform SDK 没有Here is a way to enable compiling with gcc 4.2 in xcode 4.2. This is mostly done via command line so when you see lines starting with:
[ 15:30 jon@MacBookPro / ]$
, you need to open up Terminal.app and run the command that starts after the$
.Download - but do not install yet - xcode_4.1_for_lion.dmg or xcode_4.1_for_snow_leopard.dmg
Now, follow these steps to install Xcode 4.1 into
/Developer-4.1
:Backup the working
/Developer
directory (where Xcode 4.2 is installed)Run the Xcode 4.1 installer using the default install location (
/Developer
)Move the new Xcode 4.1 installation to
/Developer-4.1
:Move the Xcode 4.2 developer directory back to
/Developer
:Edit the Xcode 4.2
GCC 4.2.xcspec
file to get gcc 4.2 to show in the list of compiler options [1]:Change lines 41 and 42 from this:
To This:
Backup the Xcode 4.2 iOS/Simulator Framework
usr
directories:Copy Xcode 4.1 iOS/Simulator Framework
usr
directories to Xcode 4.2:Copy the
gcc
andinfo
iOS SDK library directories from Xcode 4.1 to Xcode 4.2 [2]:Compile using gcc-4.2!
This is a blog post I've written with a little more info about this process. Feel free to leave a comment on the blog if you run into any issues or have any questions.
[1] If opening from a command line (using something like
vi
,emacs
,nano
, etc) make sure to either enclose the path in quotes "/long path/with spaces/in it/file.xcspec" or escape the spaces /some/long\ path/with\ spaces/in\ it/file.xcspec[2] This is necessary because the iPhoneOS.platform SDK has its own seperate
/usr/lib
directories but the iPhoneSimulator.platform SDK does notXcode 4.2的默认编译器是LLVM 3.0。 Apple 正在从 LLVM 转向 GCC 4.2,GCC 4.2 仍然作为一个选项提供。然而 GCC 4.2 已经永远消失了。
我想你除了寻找与 LLVM 3.0(最好)或 LLVM GCC 4.2 一起使用的不同代码覆盖解决方案之外别无选择,或者等到有人提供这样的工具。毕竟,Xcode 4.2 相对较新,代码覆盖率也相对重要,因此我确信最终会出现一个可行的解决方案。
The default compiler of Xcode 4.2 is LLVM 3.0. Apple is moving away from LLVM to GCC 4.2, which is still available as an option. GCC 4.2 however is gone for good.
I suppose you have no option other than finding a different code coverage solution that works with LLVM 3.0 (preferably) or LLVM GCC 4.2, or wait until someone provides such a tool. After all, Xcode 4.2 is relatively new and code coverage relatively important, so I'm sure eventually a working solution will surface.