2

After using XCode 5.1, I got an error like this:

gcov: Unknown command line argument '-v'.  Try: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/gcov -help'

Then I find an answer from this page: XCode 5.1 Unit Test Coverage Analysis Fails On Files Using Blocks

However, I got another error like this:

Processing *****.gcda
File checksums do not match: 1280071245 != 5 in ().
Invalid .gcno File!
geninfo: ERROR: GCOV failed for ****.gcda!
Community
  • 1
  • 1
detinqq
  • 21
  • 3

1 Answers1

0

For me the cause was that the *.gcno files were stale and did not match the *.gcda files. In fact most of them had gone missing.

Fixed this by doing the following:

  • Ensured that both: 'instrument program flow' and 'generated test coverage' were set in both the App's target and the test target.

I then added the following to the AppDelegate.

- (void)applicationWillTerminate:(UIApplication *)application
{
    extern void __gcov_flush(void);
    __gcov_flush(); //ensure all coverage data is flushed before shutdown
}

. . this is for application hosted iOS tests. Depending on your requirements you could make this a little less 'invasive' (eg, mix in the coverage flushing so that its only in your test target), but this should be a good starting point to get it working first.

Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
  • Also note that with the current version of Xcode, there's a new version of gcov. If you're using the lcov tool to generate HTML reports, you need to hack the geninfo script as it doesn't know about llvm-gcov yet. Details: http://stackoverflow.com/a/22404544/404201 – Jasper Blues May 31 '14 at 01:05