Xcode 4.2 代码覆盖率

发布于 2024-12-10 01:00:38 字数 376 浏览 0 评论 0原文

我开始使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

︶葆Ⅱㄣ 2024-12-17 01:00:38

此博客有一个很好的有关如何使用 LLVM 实现与 gcc 兼容的覆盖率结果的教程。

当前 LLVM 前端中提供了覆盖功能,但它似乎并未公开
在 XCode 附带的当前版本中。

我同意作者的观点,它可以是编译您自己的版本以进行覆盖的解决方案
目的并坚持使用交付的版本来生成最终的二进制文件。

我还值得注意的是,他的教程声称:

Since Clang outputs these files in the same format as GCC,
they are compatible with tools such as CoverStory.

也许这对你有用。

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:

Since Clang outputs these files in the same format as GCC,
they are compatible with tools such as CoverStory.

Maybe this is of some use to you.

笨笨の傻瓜 2024-12-17 01:00:38

这是一种在 xcode 4.2 中启用 gcc 4.2 编译的方法。这主要是通过命令行完成的,因此当您看到以以下开头的行时:[ 15:30 jon@MacBookPro / ]$,您需要打开Terminal.app并运行在 $ 之后开始的命令。

在此过程中不会删除删除任何文件或目录,因此如果您将来需要使用 LLVM 进行编译,可以轻松撤消。

  1. 下载 - 但暂时不要安装 - xcode_4.1_for_lion.dmgxcode_4.1_for_snow_leopard.dmg< /p>

  2. < p>现在,按照以下步骤将 Xcode 4.1 安装到/Developer-4.1

    1. 备份工作 /Developer 目录(安装 Xcode 4.2 的位置)

    2. [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
      
    3. 使用默认安装位置 (/Developer) 运行 Xcode 4.1 安装程序

    4. 将新的 Xcode 4.1 安装移至 /Developer-4.1

      [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
      
    5. 将 Xcode 4.2 开发人员目录移回 /Developer

      [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer
      
  3. 编辑 Xcode 4.2 GCC 4.2.xcspec 文件以获取 gcc 4.2在编译器选项列表中显示[1]

    [ 15:30 jon@MacBookPro / ]$ sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/ Xcode/插件/GCC 4.2(合理块).xcplugin/Contents/Resources/GCC 4.2.xcspec"
    
    • 4142 行从此更改:

      ShowInCompilerSelectionPopup = NO;
      不再支持=是;
      
    • 致此:

      ShowInCompilerSelectionPopup = YES; 
      不再支持=否;
      
  4. 备份 Xcode 4.2 iOS/Simulator Framework usr 目录:

    [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform /开发者/usr.backup
    [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneSimulator.platform/Developer/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr.backup
    
  5. 将 Xcode 4.1 iOS/Simulator Framework usr 目录复制到 Xcode 4.2:< /p>

    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS .platform/开发者/usr
    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr
    
  6. 复制 gccinfo从 Xcode 4.1 到 Xcode 4.2 的 iOS SDK 库目录[2]

    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk /usr/lib/gcc /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc
    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/info /Developer/Platforms/iPhoneOS.platform/Developer /SDKs/iPhoneOS5.0.sdk/usr/lib/info
    
  7. 使用gcc-4.2编译!

    xcode 4.2 中 CGG 4.2 的屏幕截图

这是一个我写的博客文章提供了有关此过程的更多信息。如果您遇到任何问题或有任何疑问,请随时在博客上发表评论。


[1] 如果从命令行打开(使用类似 viemacsnano 等)确保将路径用引号括起来 "/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 $.

No files or directories are removed or deleted in this process, so it is easy to undo if you need to compile with LLVM in the future.

  1. Download - but do not install yet - xcode_4.1_for_lion.dmg or xcode_4.1_for_snow_leopard.dmg

  2. Now, follow these steps to install Xcode 4.1 into /Developer-4.1:

    1. Backup the working /Developer directory (where Xcode 4.2 is installed)

    2. [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
      
    3. Run the Xcode 4.1 installer using the default install location (/Developer)

    4. Move the new Xcode 4.1 installation to /Developer-4.1:

      [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
      
    5. Move the Xcode 4.2 developer directory back to /Developer:

      [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer
      
  3. Edit the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options [1]:

    [ 15:30 jon@MacBookPro / ]$ sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2 (Plausible Blocks).xcplugin/Contents/Resources/GCC 4.2.xcspec"
    
    • Change lines 41 and 42 from this:

      ShowInCompilerSelectionPopup = NO;
      IsNoLongerSupported = YES;
      
    • To This:

      ShowInCompilerSelectionPopup = YES; 
      IsNoLongerSupported = NO;
      
  4. Backup the Xcode 4.2 iOS/Simulator Framework usr directories:

    [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr.backup
    [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneSimulator.platform/Developer/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr.backup
    
  5. Copy Xcode 4.1 iOS/Simulator Framework usr directories to Xcode 4.2:

    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr
    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr
    
  6. Copy the gcc and info iOS SDK library directories from Xcode 4.1 to Xcode 4.2 [2]:

    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/gcc /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc
    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/info /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/info
    
  7. Compile using gcc-4.2!

    Screenshot of CGG 4.2 in xcode 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 not

冰之心 2024-12-17 01:00:38

Xcode 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文