Xcode 4.2的代码覆盖率 - 缺少文件 [英] Code coverage with Xcode 4.2 - Missing files

查看:124
本文介绍了Xcode 4.2的代码覆盖率 - 缺少文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着 Claus的帖子使用LLVM 3.0在Xcode 4.2上设置代码覆盖率。我能够看到测试覆盖文件,但它们只适用于我的单元测试类,而不是我的实际项目类。我已尝试在我的主要目标上将生成测试覆盖率文件仪器程序流程设置为,但这没有帮助,因为它失败并出现以下错误:

I followed Claus's post to set up code coverage on Xcode 4.2 with LLVM 3.0. I'm able to see test coverage files, but they're only for my unit test classes, not my actual project classes. I've tried setting Generate Test Coverage Files and Instrument Program Flow to Yes on my main target, but that didn't help, as it failed with the following error:

fopen $ UNIX2003从函数llvm_gcda_start_file调用

fopen$UNIX2003 called from function llvm_gcda_start_file

澄清一下,我不知道认为这是正确的方法 - 我只是试着看它是否会在我的项目类中生成代码覆盖。

To clarify, I don't think that's even the right approach - I just tried it to see if it would generate code coverage on my project classes.

此时,我很乐意尝试任何可以在我的应用上运行代码覆盖的东西。有什么建议?

At this point, I'd be happy to try anything that gets code coverage working on my app. Any suggestions?

推荐答案

您期待链接器问题, profile_rt 库使用 fopen $ UNIX2003 fwrite $ UNIX2003 函数而不是 fopen fwrite

You are expecting linker problem, profile_rt library uses fopen$UNIX2003 and fwrite$UNIX2003 functions instead of fopen and fwrite.

您只需要添加以下 .c 文件到你的项目:

All you need is to add the following .c file to your project:

#include <stdio.h>

FILE *fopen$UNIX2003( const char *filename, const char *mode )
{
    return fopen(filename, mode);
}

size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
    return fwrite(a, b, c, d);
}

此代码只是将缺少的函数重新映射为标准函数。

This code just remaps the missing functions to standard ones.

注意 $ UNIX2003 后缀:

Note on $UNIX2003 suffix:

我发现 Apple文档说:


UNIX™一致性变体使用$ UNIX2003后缀。

The UNIX™ conformance variants use the $UNIX2003 suffix.

重要:UNIX™的工作一致性在Mac OS 10.4中开始,但直到10.5才完成。因此,在10.4版本的libSystem.dylib中,存在许多符合变体的符号(带有$ UNIX2003后缀)。列表不完整,变体符号的符合行为可能不完整,因此应避免使用。

Important: The work for UNIX™ conformance started in Mac OS 10.4, but was not completed until 10.5. Thus, in the 10.4 versions of libSystem.dylib, many of the conforming variant symbols (with the $UNIX2003 suffix) exist. The list is not complete, and the conforming behavior of the variant symbols may not be complete, so they should be avoided.

因为64位环境没有遗留给维护,它从一开始就被创建为符合UNIX™,而不使用$ UNIX2003后缀。因此,例如,32位的_fputs $ UNIX2003和64位的_fputs将具有相同的符合行为。

Because the 64-bit environment has no legacy to maintain, it was created to be UNIX™ conforming from the start, without the use of the $UNIX2003 suffix. So, for example, _fputs$UNIX2003 in 32-bit and _fputs in 64-bit will have the same conforming behavior.

所以我期望 libprofile_rt 与10.4 SDK链接。

So I expect libprofile_rt to be linked against 10.4 SDK.

这篇关于Xcode 4.2的代码覆盖率 - 缺少文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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