Xcode 13 coverage report fail

Since Xcode 13 the coverage of my project is missing, from locally and Azure, I discovered that only fails on simulator, in a real device all works fine as always, any idea?

This is the error from Xcode when the tests end:

Failed to merge raw profiles in directory /.../Coverage.profdata: Aggregation tool '/.../Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata' failed with exit code 1

Thanks a lot

Could you file a feedback assistant at feedbackassistant.apple.com with the contents of your project's DerivedData directory after you've run your tests?

Xcode invokes the llvm-profdata tool to merge LLVM code coverage profiles together into an aggregate profile (Coverage.profdata). This can fail if one or more of the profiles it is trying to merge are malformed. If you can send us a copy of your project's DerivedData folder, we can inspect the profiles and see if that is the culprit.

We also have this issue with our app. How can we debug to find out the culprit?

Any news on this? Our PR pipeline is blocked without code coverage?

We have always been using the following code in our PR pipeline for years and it worked.

xcodebuild -sdk iphoneos -configuration dev -workspace MyProject.xcworkspace -scheme MyProject_Mu -destination 'platform=iOS Simulator,name=iPhone 8' test -derivedDataPath DerivedData CODE_SIGNING_ALLOWED=NO

Normally, the above code generated .profraw and .profdata at folder: DerivedData/Build/ProfileData/41E444A5-D124-4222-82C2-EB33DCDBF2FC/

Until recently, our hosted agent upgraded from XCode 12 to XCode 13, the above code generates only the .profraw and ends with the error below

warning: DerivedData/Build/ProfileData/41E444A5-D124-4222-82C2-EB33DCDBF2FC/B8590BD3-CF44-4308-95CF-20FBFFEF3568-24496.profraw: Failed to uncompress data (zlib)
error: No profiles could be merged.

We even tried to run this code hoping this would fix the issue:

xcrun llvm-profdata merge DerivedData/Build/ProfileData/*/*.profraw -output generated.profdata

But it does not work. We get the same error

warning: DerivedData/Build/ProfileData/41E444A5-D124-4222-82C2-EB33DCDBF2FC/B8590BD3-CF44-4308-95CF-20FBFFEF3568-24496.profraw: Failed to uncompress data (zlib)
error: No profiles could be merged.

Now our PR pipeline is stuck and we can't work because this script is needed to generate unit test coverage data. And the pipeline is always failing.

Same issue here. I figured out that initialisation of AVPlayerLayer() in our code causes the issue.

Xcode 13.3

We're seeing this issue in our app as well. We've been able to narrow it down to obj-c unit tests that use OCMock. Not sure why that's the case but tests that don't have OCMock can generate code coverage just fine.

Luckily our app has an tvOS target as well and there the coverage is working. Some test code, same implementation code, I simply added the tvOS target membership for our test files.

Xcode 13 coverage report fail
 
 
Q