Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 7.0 and 7.1, code coverage turned ON, unit test crash "cannot merge previous GCDA file: corrupt arc tag"

We have been having this problem since Xcode 7 beta and the problem persists to this day with Xcode 7.1.

Basically we cannot turn ON code coverage in Xcode. In Xcode 6, this worked fine, but has been broken ever since Xcode 7. At the end of a unit test run, we get infinite console output saying:

profiling: /Users/<my path to app>/ObjectiveC.gcda: cannot merge previous GCDA file: corrupt arc tag (<some hex address>)

This output repeats until the app crashes. I just have no idea why this is happening and all attempts to fix this issue have failed (except for turning off instrumenting program flows and turning off code coverage). I even tried setting up a build phase run script that finds and clears the previous code coverage files, but that did not work either.

Has anyone figured this out?

like image 965
n8tr Avatar asked Oct 18 '22 23:10

n8tr


2 Answers

Thanks @gagarwal for the direction. I'll just have to figure out a different jenkins reporting tool since the old code coverage files were needed, but I suppose that isn't supported anymore. Here are some screenshots to illustrate the setup that generates code coverage reports viewable within Xcode based on gagarwal's sugguestions:

----------------------        
main app target config
----------------------

enter image description here enter image description here

----------------------
test app target config
----------------------

enter image description here enter image description here

------------------------------------------
Scheme config (see "Gather coverage data")
------------------------------------------

enter image description here

like image 190
n8tr Avatar answered Oct 28 '22 22:10

n8tr


Xcode 7's new code coverage features use the LLVM coverage format.

Also Xcode 7 has new build settings for code coverage: "CLANG_ENABLE_CODE_COVERAGE"

Make sure "CLANG_ENABLE_CODE_COVERAGE" is set to "YES" and following to NO:

GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO;

like image 31
gagarwal Avatar answered Oct 28 '22 21:10

gagarwal