From f1c430cb22c60862e7250ca5065c6592b3cb50ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Mon, 1 Jun 2026 22:16:51 +0200 Subject: [PATCH] fix(coverage-ios): support universal binaries and fix podspec metadata Pass -arch to llvm-cov export when the app binary is a universal/fat Mach-O (simulator builds with arm64 + x86_64), preferring arm64. Add author and homepage to coverage-ios package.json so the HarnessCoverage podspec passes CocoaPods validation. --- packages/coverage-ios/package.json | 4 +++- packages/platform-ios/src/coverage-collector.ts | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/coverage-ios/package.json b/packages/coverage-ios/package.json index c0cb710b..12412875 100644 --- a/packages/coverage-ios/package.json +++ b/packages/coverage-ios/package.json @@ -33,5 +33,7 @@ "devDependencies": { "react-native": "*" }, - "license": "MIT" + "license": "MIT", + "author": "Callstack", + "homepage": "https://github.com/callstackincubator/react-native-harness" } diff --git a/packages/platform-ios/src/coverage-collector.ts b/packages/platform-ios/src/coverage-collector.ts index 0a214398..dfc099a9 100644 --- a/packages/platform-ios/src/coverage-collector.ts +++ b/packages/platform-ios/src/coverage-collector.ts @@ -98,11 +98,24 @@ export const generateLcov = async (options: { }): Promise => { const { profdataPath, binaryPath, outputPath, sourceFilters } = options; + // llvm-cov needs an explicit -arch for universal/fat binaries (e.g. Xcode 26 + // debug.dylib). The profile data was produced by the simulator's execution + // arch, which matches the host: arm64 on Apple Silicon, x86_64 on Intel. + const { stdout: archs } = await spawn('lipo', ['-archs', binaryPath]); + const archList = archs.trim().split(/\s+/); + let archFlag: string[] = []; + if (archList.length > 1) { + const { stdout: hostArch } = await spawn('uname', ['-m']); + const arch = hostArch.trim(); + archFlag = ['-arch', archList.includes(arch) ? arch : archList[0]]; + } + const args = [ 'llvm-cov', 'export', '-format=lcov', `-instr-profile=${profdataPath}`, + ...archFlag, binaryPath, ];