Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
CoverageFopenFix
ExportHtml.automator
ExportHtmlComment.txt
FixBrokenCoverage.c
README.md
libCoverageFopenFix.a

README.md

Implementing code coverage for iOS projects

Project settings

  • Generate Test Coverage Files (GCC_GENERATE_TEST_COVERAGE_FILES): YES
  • Instrument Program Flow (GCC_INSTRUMENT_PROGRAM_FLOW_ARCS): YES
  • Add a fopen hack to your application (not the tests bundle), see below. Alternatively you can link to libCoverageFopenFix.a that includes the fix.

Note: you do not need to link to profile_rt in recent Xcode!

Consider adding new configuration "Coverage" (based on Debug configuration) for these options.

Viewing coverage results

CoverStory is a great OS X application for viewing coverage results.

A hack to make SDK happy

#include <stdio.h>

FILE *fopen$UNIX2003(const char * __restrict, const char * __restrict);
FILE *fopen$UNIX2003( const char *filename, const char *mode )
{
    return fopen(filename, mode);
}

size_t fwrite$UNIX2003(const void * __restrict, size_t, size_t, FILE * __restrict);
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
    return fwrite(a, b, c, d);
}

Add the code above to any .c file that is going to be linked into your application (must be in app itself, not the tests bundle). You can find this file in the source tree above. Alternatively, you can link libCoverageFopenFix.a to it. This is a "fat" library that can be used both with for device and the simulator build.