No profiles could be merged error during code coverage stage in jenkins with Xcode 13

When we build the project in jenkins with Xcode 13 agent, in code coverage stage getting bellow error:

warning: /Users/jenkins/jenkins/pipeline_PR-1625/DerivedData-app/Build/ProfileData/2EE1905D-E25C-4A2B-9440-42EF7BF5DC79/4ABFFAFB-F58E-4195-9138-BA3DFD9DAA2D-84652.profraw: Invalid instrumentation profile data (bad magic)

error: No profiles could be merged.

Can anyone guide us in resolving this issue.

Even when it is build locally, test succedes, but fails to gather code coverage data and fails with the error failed to merge raw profiles in directory

Also I observed it is failing to generate Coverage.profdata file inside DerivedData/build/Profiledata

Also I observed it is failing to generate Coverage.profdata file inside DerivedData/build/Profiledata

Disabling the code coverage for the pod repos inside pod project resolved this issue

Add bellow script in Podfile to disable the code coverge

config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'

config.build_settings['swiftc'] = '$(SRCROOT)/SWIFT_EXEC-no-coverage'

We spent really a lot of time debugging this, it appears that one of our dependencies was a binary (xcframework), most probably distributed via older version of the XCode, after updating this dependency coverage was back.

No profiles could be merged error during code coverage stage in jenkins with Xcode 13
 
 
Q