Xcode Code Coverage results

I've found that Xcode 7 seems to generate its code coverage results on a xccoverage file inside Logs/Test on my project's derived data folder.


Is there a way to get this file name from xcodebuild? Also, is there a way to convert it to another format (gcov or Cobertura XML for example)?

Accepted Reply

That tech note describes using gcov, and is not part of Xcode 7's code coverage support. For Xcode 7, there's a Coverage.profdata file that's produced down inside the CodeCoverage directory of the Intermediates folder of your project's build directory. That file can be read by the llvm-cov command line tool.

Replies

See: QA1514: Technical Q&A QA1514: Configuring Xcode for Code Coverage


...it explains how to save that file to your choice of location.


You may need to use Report Bugs to make a feature request if you'd like the ability to convert/export.

◅▻

That Q&A was last updated in 2014 and is refering to GCOV code coverage.


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

Actually, it explains how to save for using with GCOV. The new code coverage feature on Xcode 7 creates a ".xccoverage" file, which is a binary plist.


I filled a bug report: http://www.openradar.me/21369366

You can find more information here:

http://llvm.org/docs/CoverageMappingFormat.html

That tech note describes using gcov, and is not part of Xcode 7's code coverage support. For Xcode 7, there's a Coverage.profdata file that's produced down inside the CodeCoverage directory of the Intermediates folder of your project's build directory. That file can be read by the llvm-cov command line tool.

Hi Dave,


Thanks for the answer! I have installed llvm-cov (as part os llvm), but I'm not very familiar with the toolset. I think I should use "llvm-cov report", but I'm not sure how to proceed. Could you give an example?

Did you figure out how to call llvm-cov with the files generated by Xcode 7?

I've just started with this one:

xcrun llvm-cov report -use-color=false \
-instr-profile ./Output/MyApp/iphonesimulator/Build/Intermediates/CodeCoverage/MyApp/Coverage.profdata \
./Output/MyApp/iphonesimulator/Build/Intermediates/CodeCoverage/MyApp/Products/Debug-iphonesimulator/MyApp.app/MyApp


Some guys also suggest to look to https://github.com/venmo/slather

(https://stackoverflow.com/questions/31040594/how-to-generate-gcov-file-from-llvm-cov)

I get the below mentioned error when I try the exact cmd . I am trying to generate coverage report for static library.

So instead of MyApp.app/MyAppTest I specify MyStaticLib.a and I get the error :


error: Failed to load coverage: Invalid data was encountered while parsing the file