xcrun llvm-cov show: No coverage data found

3.1k views Asked by At

What are the possible reasons for xcrun llvm-cov show command to return error: Failed to load coverage: No such file or directory?

I have an iOS lib. The result of the lib build is *.a binary file. I have a scheme in the project which also contains GTest unit tests.

So I execute:

xcodebuild test \
-sdk iphonesimulator \
-destination "$DESTINATION" \
-derivedDataPath "$ROOT"/DerivedData \
-scheme unitTestsTarget \
-project "$ROOT"/libProject.xcodeproj \
-enableCodeCoverage YES

After that

xcrun llvm-profdata merge .../Coverage.profdata .../EA8FF09E-3BFE-42D2-BFA7-A39D69E7F688-45921.profraw -output ./merged.profdata

And

xcrun llvm-cov show -format=html -use-color=true -output-dir=./coverage-html -instr-profile ./merged.profdata -object ./DerivedData/Build/Products/Debug-iphonesimulator/myLib.a -ignore-filename-regex='\''.*\.h'\'''

And the last command gives me

error: ./myLib.a: Failed to load coverage: No such file or directory

I have 3 modules of a similar structure and one of them works fine and the other 2 give me this error.

I'd really appreciate is someone can give a hint on the possible reasons for this error and possible solutions to try.

1

There are 1 answers

1
Benzi On BEST ANSWER

I faced the same issue with my static lib that Xcode was building.

With some exploration, I noticed that passing in explicit .o files generated during the build seemed to work, but output was limited to just that file.

xcrun llvm-cov report \
    --instr-profile=Build/ProfileData/40F9DE10-F76F-46C0-A8D2-E1D427DE08A5/Coverage.profdata \
    --object Build/Intermediates.noindex/MyStaticLib.build/Debug-iphonesimulator/MyStaticLib.build/Objects-normal/x86_64/some_file.o

I tried to manually link all these .o files present in the Build folder as follows, to generate a combined object file:

ld -r -o CombinedObject.o \ 
    Build/Intermediates.noindex/MyStaticLib.build/Debug-iphonesimulator/MyStaticLib.build/Objects-normal/x86_64/*.o

Following which, I was able to run and get the coverage report.

xcrun llvm-cov report \
    --instr-profile=Build/ProfileData/40F9DE10-F76F-46C0-A8D2-E1D427DE08A5/Coverage.profdata \
    CombinedObject.o

So essentially I had to combine the individual .o files to a combined object file, which then llvm-cov was able to process.