Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS code coverage broken in Xcode 4.5?

I'm trying to set up code coverage in Xcode 4.5. To do so, I turned on Generate Test Coverage Files and Instrument Program Flow for debug setting. According to http://meandmark.com/blog/2012/08/xcode-4-generating-code-coverage-files-with-llvm/ that's all you need. However, now the linker complains that it can't find:

  • _llvm_gcda_emit_arcs
  • _llvm_gcda_emit_function
  • _llvm_gcda_end_file
  • _llvm_gcda_increment_indirect_counter
  • _llvm_gcda_start_file

I tried to find libprofile_rt.dylib, but it doesn't seem to exist anymore. What else is needed to generate code coverage files?

like image 356
Karl Avatar asked Oct 01 '12 08:10

Karl


People also ask

What is code coverage in Xcode 7?

Code coverage is a feature in Xcode 7 that enables you to visualize and measure how much of your code is being exercised by tests. With code coverage, you can determine whether your tests are doing the job you intended.

How do I view LLVM coverage in Xcode?

After a test run is completed, Xcode takes the LLVM coverage data and uses it to create a coverage report in the Reports navigator, seen in the Coverage pane. It shows summary information about the test run, a listing of source files and functions within the files, and coverage percentage for each.

What does the code coverage option do?

The code coverage option can collect data to report on tests of correctness and of performance, whether unit tests or UI tests. You enable code coverage by editing the scheme's Test action.

How do I enable code coverage for a test?

The code coverage option can collect data to report on tests of correctness and of performance, whether unit tests or UI tests. You enable code coverage by editing the scheme's Test action. Select Edit Scheme from the scheme editor menu.


2 Answers

Under the target build setting (be sure to select all)

Set:

  • Apple LLVM complier
    • Instrument Program Flow: YES
    • Generate Test Coverage Files: YES
like image 140
Eric Avatar answered Sep 19 '22 08:09

Eric


I also ran into these linker errors. I saw the errors using Xcode 4.2 and 4.3. I'm not sure if they still are there in 4.5.

To solve it I added this file from the llvm project to my unit test code project. To get it to build on my Mac I deleted the win32 and sys includes and replaced the #include "llvm/Support/DataTypes.h" include with #include "stdint.h".

like image 38
Gerard Condon Avatar answered Sep 18 '22 08:09

Gerard Condon