Infinite Loop

Code Coverage and fopen$UNIX2003 Problems

A couple of readers have reported they were unable to get code coverage on LLVM working properly after following my description in Code Coverage with Xcode 4.2. The problem would manifest itself in a somewhat cryptic error during execution of the unit tests:

Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
fopen$UNIX2003 called from function llvm_gcda_start_file

The discussions have been lively with various suggestions on tweaking compiler flags, inclusion of libraries, missing files in target, etc. It wasn’t until I ran into the problem myself – even after following my own advice step by step – that I decided to dig deeper into the cause of the problem. Fortunately it turned out that the solution had already been described in the discussions and it’s a rather simple one too.
(more…)

Bookmark and Share
Comments (1) | Trackback

Code Coverage with Xcode 4.2

This tutorial is just a small follow-up on one of my earlier posts about how to set up code coverage in Xcode.

With the release of Xcode 4.2 code coverage is finally supported using Clang / LLVM. Opposed to what I described in the earlier post you no longer need to force the use of GCC to get code coverage metrics in your unit tests. Since Apple has also decided to drop support for GCC you are more or less forced to switch to Clang / LLVM anyway.

In Xcode 4.2 it’s fairly simple to set up code coverage. If you have defined a custom build setting or build rule that enforces GCC 4.2 you will need to remove those first.

Next you’ll need to enable the two build settings “Generate Test Coverage Files” and “Instrument Program Flow” as shown below:


(more…)

Bookmark and Share
Comments (15) | Trackback