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