'XCode 13 failed to generate profdata file

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.



Solution 1:[1]

I solved the issue by setting GCC_INSTRUMENT_PROGRAM_FLOW_ARCS to NO. For some reason the extra code added by LLVM profiling instrumentation is interfering with the code coverage. I am not sure if this is the expected behavior I will file a bug and follow up if I have any further information. I hope this is the reason for others that face the same problem

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Christos Koninis