Xcode 4.2代码覆盖率 [英] Xcode 4.2 Code Coverage

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

问题描述



Xcode 4.2不包含GCC 4.2编译器,但它被替换为LLVM GCC 4.2编译器。
首先需要在前一版本的Xcode中生成代码覆盖率。



我跟着CoverStory上的'tutorial'






[1] 如果从命令行打开(使用类似于 vi emacs nano 等)请确保将路径用引号括起来/ long path / with spaces / in it / file.xcspec kbd>或者跳过空格 / some / long \ path / with \ spaces / in\ it / file.xcspec



这是必要的,因为iPhoneOS.platform SDK有它自己的独立 / usr / lib 目录,但iPhoneSimulator.platform SDK不会

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

解决方案

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!

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

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

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