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.
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.I tried to manually link all these
.o
files present in the Build folder as follows, to generate a combined object file:Following which, I was able to run and get the coverage report.
So essentially I had to combine the individual
.o
files to a combined object file, which thenllvm-cov
was able to process.