iOS上的代码覆盖率在Lion上使用Xcode 4.2 [英] Code coverage on iOS Using Xcode 4.2 on Lion

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

问题描述

我正在尝试从Lion上的一个名为CocoaTouchHax的iOS Xcode 4.2(4D199)项目中生成gcd文件,我遇到了不可思议的麻烦。我按照此处的步骤进行操作,然后我尝试构建llvm / clang从以下步骤此处开始。但是我继续收到此错误:

I'm trying to produce gcd a files from an iOS Xcode 4.2 (4D199) project called CocoaTouchHax on Lion and I'm having incredible trouble. I followed the steps here and I went as far as trying to build llvm/clang from source following steps here. However I continue to get this error:

Library not loaded: @executable_path/../lib/libprofile_rt.dylib

我哪里错了?我试图使用install_name_tool修复可执行路径无济于事。我在分析什么吗?我错过了一些简单的事吗?我在链接之前将其作为运行脚本阶段,以确保我已更新@executable路径,并使用工具检查文件后更新名称:

Where am I going wrong? I've tried to use the install_name_tool to fix the executable path to no avail. Am I over analyzing something? Am I missing something simple? I put this in as a "Run Script" phase prior to linking to ensure I've updated the @executable path and I use tool to examine the file after and the name is updated:

install_name_tool -id @executable_path/Users/cliff/dev/CocoaTouchHax/build/CocoaTouchHax/Build/Products/Debug-iphonesimulator/lib/libprofile_rt.dylib build/CocoaTouchHax/Build/Products/Debug-iphonesimulator/lib/libprofile_rt.dylib

我做错了什么?帮助!

更新
仅仅添加lib profile_rt.dylib会立即崩溃我的测试运行,并在运行任何内容时出现以下错误:
@executable_path /../ lib / libprofile_rt.dylib
所以我确定在执行之前需要对lib profile_rt.dylib进行某些操作或需要做些什么。

Update Merely adding lib profile_rt.dylib crashes my test run immediately giving the following error when anything is run: @executable_path/../lib/libprofile_rt.dylib So I am certain that something needs to happen or something needs to be done to the lib profile_rt.dylib prior to execution.

另一次更新我尝试在/Developer/Platforms/iPhoneSimulator.platform/Developer/下创建
/ Developer / usr / lib
的和链接SDKs / iPhoneSimulator5.0.sdk / Developer / usr
我认为这是测试运行时形成当前工作目录的路径的基础的一部分。 (假设它从那里的bin文件夹运行。)理论上,这将从该基本路径完成../lib/libprofile_rt.dylib的相对查找路径,但它不起作用。我已经尝试在复制dylib之前运行install_name_tool命令,但我仍然收到此错误:

Another Update I tried creating a sum link to /Developer/usr/lib under /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/usr Which I believe is part of the base the path forming the current working directory when test runs. (Assuming it runs from the bin folder there.) This would, in theory, complete the relative lookup path of ../lib/libprofile_rt.dylib from that base path but it didn't work. I've tried running the install_name_tool command prior to copying the dylib in place but I still get this error:


未加载库:@executable_path /../ lib / libprofile_rt.dylib

Library not loaded: @executable_path/../lib/libprofile_rt.dylib

我不知道我做错了什么。我不知何故设法使用上面的一些组合来获取测试覆盖文件,但我没有给予足够的关注,也无法重现出现。我知道这可以工作,我只需要更多的帮助来弄清楚如何。

I don't know what I'm doing wrong. I somehow did manage to get test coverage files to emit using some combination of the above but I was not paying close enough attention and cannot reproduce the occurance. I know this can work, I just need a little more help figuring out how.

推荐答案

在Lion上你可以将dylib符号链接到/ usr / lib以避免该错误

On Lion you can symlink the dylib into /usr/lib to avoid that error

sudo ln -s /Developer/usr/lib/libprofile_rt.dylib / usr / lib / libprofile_rt。 dylib

我不能保证不会破坏未来的事情。请记住,你已经做到了。

I cant guarantee that that wont bust something the future however. Remember that you have done it.

创建一个名为Coverage(或其他)的新配置。

Create a new configuration called "Coverage" (or whatever).

在Coverage配置变体中,您有创建转到构建设置和...

In the Coverage config variant you have created go to Build Settings and...


  • 添加 -fprofile-arcs -ftest-coverage 其他C标志

  • 启用生成测试覆盖率文件

  • 启用工具程序流程

  • 其他链接器标记添加 -lprofile_rt

  • Add -fprofile-arcs and -ftest-coverage to Other C Flags
  • Switch on Generate Test Coverage Files
  • Switch on Instrument Program Flow
  • In Other Linker flags add -lprofile_rt

原因用配置这样做是因为你可以保持你的正常构建不受影响。也只适用于模拟器。所以不要尝试在设备上运行它。

The reason to do it this way with a config is that you can keep your normal build untouched. Also only works on Simulator. So dont try running this on device.

并且来自 http://mattrajca.com/post/8749868513/llvm-code-coverage-and-xcode-4

最后,打开Intermediates / $ TARGET.build / $ CONFIG / $ TARGET.build / Objects-normal / $ ARCH子文件夹。在里面,你会找到上面提到的gcda和gcov文件

你可以用CoverStory打开那个文件夹。

You can open that folder with CoverStory.

请注意,覆盖范围不是累积的(与Coverity不同),因此每次运行都会重新开始。可能有办法改变这种状况。

Note that coverage is not cumulative (unlike Coverity) so each run starts afresh. There might be a way to change that.

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

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