I am using Xcode 3.2 on 10.6, with the shipped version of gcov and default GCC compiler (both version 4.2.1). I have created a dependent Cocoa unit test bundle which is injected into my app, and followed Apple's documentation on setting up a gcov-instrumented build configuration - based on the Debug configuration which doesn't have any compiler optimisations enabled.
When I build the test bundle with this 'Gcov-instrumented' configuration, the app launches and the tests are injected and run. Also the coverage statistics files are generated at:
build/<AppTarget>.build/Gcov-instrumented/<AppTarget>.build/Objects-normal/x86_64/<object>.gcda
build/<AppTarget>.build/Gcov-instrumented/<AppTarget>.build/Objects-normal/x86_64/<object>.gcno
So far so good. I know the tests are really being run because if I insert failures then the test suite fails as expected. Unfortunately, gcov reports that no lines of the objects have been covered by the tests! Every line is reported as 0 coverage. I've searched here and at the Apple mailing list archives, and can't find anyone with a similar problem. I expect I'm missing something - but what is it?
I have been running into this problem intermittently. I stumbled into a good length of lucky time where it was "mostly working" in my main project. By mostly working I mean I was able to get coverage to show up, but with a little more pain than on 10.5. I had to aggressively delete the coverage files and rebuild in order to get any updates, for instance. Even in my "barely working" state, the compiler/runtime doesn't seem willing to overwrite an existing coverage data file.
I think I've stumbled back on to a working scenario. Voodoo for sure, and less than ideal:
Does this get you the expected coverage data?
Granted, I would expect to be able to generate coverage files that work using gcc 4.2 or one of the LLVM compilers, but for the moment this seems to have me slightly less crippled than before.
Another clue: when I observe the coverage data (using Google's Cover Story), I get warnings like:
/BUILDRESULTS/MarsEdit.build/Code Coverage/MarsEditDataModelTests.build/Objects-normal/i386/MEDataItem.gcno:version '400A', prefer '402*'
But the coverage information is still presented. So it seems it's balking at an older coverage format version, but if I use the newer compiler (4.2) which would presumably generate the newer format .gcno
files, the 0% coverage problem plagues me as it does Graham.