feat: Native iOS code coverage support#83
Conversation
|
@mfazekas is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
6a33bbf to
8cd29d8
Compare
|
@V3RON any feedback on this PR adding native code coverage?! |
|
Hey @mfazekas 👋 |
Add LLVM source-based profiling for native Swift/ObjC code via a new @react-native-harness/coverage-ios package. Users specify pods to instrument in rn-harness.config.mjs and coverage flags are injected automatically at pod install time via Module.prepend on Pod::Installer.
Fix repo URLs (margelo -> callstackincubator) and extract config loading into a separate script using @react-native-harness/config.
8cd29d8 to
4035c23
Compare
- Guard podspec require_relative and install_modules_dependencies - Add @objc name annotation to prevent Swift name mangling - Defer +load class lookup to main queue for Xcode 16+ dylib compat - Read config directly instead of through Zod-validated schema - Patch app xcconfig with -force_load and -fprofile-instr-generate
The harness reinstalls the app between test files, wiping the app container. Move profraw output to /tmp/harness-coverage/ which persists across app reinstalls on the simulator. Clean the directory at test run start and after collection.
The direct config reading was a workaround for testing with the old published config package. Since this PR updates the config schema, they'll be published together and getConfig() will work correctly.
- Extract profrawDir as class-level constant - Remove debug NSLogs, keep only error log - Add one-line comment explaining ObjC +load bridge - Rename config_json to pods_json - Remove silent try/catch in resolve-coverage-pods - Remove unnecessary 500ms delay before collection - Align package.json with other packages, bump to 1.1.0
|
@V3RON sorry for the slow fix loop. I think it's ready now, can you review it again?! Thanks! |
|
Just to be sure: if there is no 'coverage-ios' package installed, Harness will still execute tests correctly, but it'll not return any data on coverage, correct? |
Yes, verified. If coverage-ios is not installed, at compile time no native code will be instrumented with coverage flags; at runtime coverage collection will return an empty result and a warning (if coverage.native.ios is configured). Existing users are not affected unless they explicitly install @react-native-harness/coverage-ios and set coverage.native.ios in their harness config. |
Summary
Adds native iOS code coverage (LLVM profiling) for Swift/ObjC code exercised by harness tests. Users specify which pods to instrument in
rn-harness.config.mjs— no Podfile changes required.Tested end-to-end with rive-nitro-react-native (RNRive + RiveRuntime pods), producing valid lcov output covering 37 source files.
Changes
@react-native-harness/coverage-iospackage with auto-linked pod and CocoaPods post-install hook-force_loadand-fprofile-instr-generatecoverage-collector.tsin platform-ios handles profraw merge and lcov export, including Xcode 16+ debug dylib binaries