Error reporting test coverage in Xcode 14.3.1

Xcode is throwing an error when attempting to report test coverage after running unit tests.

Showing All Messages
Failed to merge raw profiles in directory /{my project dir}/DerivedData/{my project name}/Build/ProfileData/A98EC493-3AB4-4B1C-B7FC-BC5D77B23EE3 to destination /{my project dir}/DerivedData/{my project name}/Build/ProfileData/A98EC493-3AB4-4B1C-B7FC-BC5D77B23EE3/Coverage.profdata: Aggregation tool '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata' failed with exit code 1: warning: /{my project dir}/DerivedData/{my project name}/Build/ProfileData/A98EC493-3AB4-4B1C-B7FC-BC5D77B23EE3/997F01E3-3735-4897-AE00-31EBB0A9E8D3-57885.profraw: invalid instrumentation profile data (file header is corrupt)
error: no profile can be merged

Anyone else seeing this issue?

We see the same top level message with XCode 14.3.x (14.2 works fine) but the underlying detail error is different for us...
Failed to merge raw.... (text omitted) .... .profraw: raw profile version mismatch: Profile uses raw profile format version = 5; expected version = 8 PLEASE update this tool to version in the raw profile, or regenerate raw profile with expected version. error: no profile can be merged

I have the same problem, any update about or workaround?

Yes, we have the same issue starting with 14.3.1. So far all beta versions Xcode 15 (just tried 15.0 beta 9) have the same problem.

Faced this issue while upgrading a project to use Xcode 15. Turns out it was failing because it had a cocoa pod dependency built with Xcode 14.0 that it didn't like, for some reason. Pulling in the dependency as a source pod fixed the coverage generation and pulling in the pod built with Xcode 15 fixed it as well.

Hopefully that helps some people!

Any update ?

I am also facing this issue

DerivedData/ProjectName-fxoxewbmvakfrffezkvexnrjwolu/Build/ProfileData/00008110-000004E21198401E/8F5E9E8E-72C8-400B-AD93-CF3A190C8B89-68902.profraw: invalid instrumentation profile data (file header is corrupt) error: no profile can be merged

while generating coverage data.

Did anyone solved the issue? We're also facing same issue after migrating from XCode 14.2 to 15.0.1. Interesting fact that this happens only to one of the our projects, another projects generates coverage report just fine.

We spent a lot of time debugging this problem, but none of the suggestions we found helped.

We tried to update our Podfile with these settings:

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

In our project Instrument Program Flow & Generate Legacy Test Coverage build settings were already set to NO

We also tried to change Mach-O type for our cocoa pods dependencies to **static library ** and many other things.

it appears that one of our dependencies was a binary (xcframework), most probably distributed via older version of the XCode, after updating it coverage was back.

I'm seeing the same issue in all of my projects on xcode 15.0.1. For folks who got it fixed, how did you figure out which upstream dependency was breaking things?

After a bunch of debugging in the llvm-profdata source code to understand how .profraw Version 8 files work, and then doing some hex editing of my corrupted output .profraw file in DerivedData to remove the corrupted section of the file, I think I have determined which framework we include that is breaking my project: MBProgressHUD.

After all of that, I was able to see a simple way of determining the included frameworks that will corrupt the ProfData:

  1. Go to the Carthage/Build folder (or wherever your included .xcframework folders are) and look at the modified date of each framework's Info.plist.
  2. Any really old ones are likely to break, and the only one I have in this project before 2023 is the one for MBProgressHUD (which is from 2021, which is definitely way before XCode 14.3).

I have this issue in Xcode 15.3

try to add configuration parameter e.g. --configuration TestDebug

I try to add new empty test target with default test file, it works when run tests for all targets.

Error reporting test coverage in Xcode 14.3.1
 
 
Q