Error in gathering code coverage in Xcode16

Fails to gather code coverage and throws this error

Showing All Messages Failed to merge raw profiles in directory /Users//Library/Developer/Xcode/DerivedData/Receiver-ekqrbpsaciuxmlfslviajhoecyat/Build/ProfileData/0B0C6B69-FD46-4801-B106-56B7FCD44370 to destination /Users//Library/Developer/Xcode/DerivedData/Receiver-ekqrbpsaciuxmlfslviajhoecyat/Build/ProfileData/0B0C6B69-FD46-4801-B106-56B7FCD44370/Coverage.profdata: Aggregation tool '/Users/shwethamugeraya/Downloads/Xcode 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata' failed with exit code 1: warning: /Users/shwethamugeraya/Library/Developer/Xcode/DerivedData/Receiver-ekqrbpsaciuxmlfslviajhoecyat/Build/ProfileData/0B0C6B69-FD46-4801-B106-56B7FCD44370/2F4EFBF7-1CCF-4E9E-8FD6-482EEDB98B6C-34646.profraw: raw profile version mismatch: Profile uses raw profile format version = 4; 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'm seeing this in 16.3 as well. Possibly due to ancient .xcframeworks injected by Carthage. An older version of Xcode should be able to view the offending .profraw files and at least dump some info to show what framework it came from. Now on Sequoia, so going back far enough is no longer an option. Boo!

I've opened Feedback: FB17628220 for this. There appears to be something wrong with the later 18.3, .4 SDKs as the profraw file that is pulled from the Simulator is just in the wrong format.

FWIW, also tested in Xcode 16.4 (iOS 18.5) and still no go.

I'm seeing the same issue in XCode26 but now it's complaining about raw profile format version = 8; expected version = 10 😢

I have figured out what's happening here. Code Coverage will ONLY work if ALL upstream dependencies have also been built with the newer version of XCode (and therefore the newer version of clang). A single profraw file will have multiple sections from the many different binaries that make up your build and each of those sections will have a header containing the raw profile version format of the clang that built that binary. For example, my framework built in XCode26 that depends on a binary framework built in XCode16.2 will have profraw headers with both 8 and 10 as the version, meaning that the resulting profraw file cannot be read in XCode26 (which can only read version 10) nor in XCode16.2 (which can only read version 8).

Error in gathering code coverage in Xcode16
 
 
Q