I'm having problems to get code coverage reporting working in Xcode 7 for a certain iOS project.
I'm following the instructions given here: http://mgrebenets.github.io/mobile%20ci/2015/09/21/code-coverage-for-ios-xcode-7/
Of the three projects I tried, two are working fine, but one project is giving me a headache. When using llvm-cov utility to generate a report from the gathered profile data like this:
xcrun llvm-cov report -instr-profile Coverage.profdata MyAppBinary
I receive the error message:
error: Failed to load coverage: The file was not recognized as a valid object file
I checked that the "Gather coverage data" is enabled for the Test scheme. I also checked that the -fprofile-instr-generate and -fcoverage-mapping compiler options are passed to clang.
File sizes and types also look valid to me:
ilMac:llvm-cov-test ilja$ ls -la
total 61976
drwxr-xr-x 4 ilja staff 136 14 Okt 21:53 .
drwxr-xr-x+ 75 ilja staff 2550 14 Okt 16:31 ..
-rw-r--r-- 1 ilja staff 1797416 14 Okt 21:53 Coverage.profdata
-rwxr-xr-x 1 ilja staff 29932040 14 Okt 16:32 MyAppBinary
ilMac:llvm-cov-test ilja$ file Coverage.profdata
Coverage.profdata: data
ilMac:llvm-cov-test ilja$ file MyAppBinary
MyAppBinary: Mach-O universal binary with 2 architectures
MyAppBinary (for architecture i386): Mach-O executable i386
MyAppBinary (for architecture x86_64): Mach-O 64-bit executable x86_64
I also noted that the "Coverage" tab in Xcode for the Test run is saying "No coverage data" instead of the indicator bars.
Any idea what I'm doing wrong?
Posting my solution in case someone will need it. Following this article code coverage xcode 7 I did following steps:
/usr/bin/xcodebuild test -workspace MyApp.xcworkspace -scheme MyAppTests -configuration DebugMyApp -destination "platform=iOS Simulator,OS=9.3,name=iPhone 6" -enableCodeCoverage YES
slather coverage \
--input-format profdata \
--cobertura-xml \
--ignore "../**/*/Xcode*" \
--output-directory slather-report \
--scheme MyAppTests \
--workspace MyApp.xcworkspace \
MyApp.xcodeproj
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With