Skip to content

chore: add Swift code coverage via LLVM profiling#190

Open
mfazekas wants to merge 2 commits intomainfrom
chore/swift-code-coverage
Open

chore: add Swift code coverage via LLVM profiling#190
mfazekas wants to merge 2 commits intomainfrom
chore/swift-code-coverage

Conversation

@mfazekas
Copy link
Copy Markdown
Collaborator

Summary

  • Opt-in Swift code coverage for ios/ files using LLVM source-based profiling
  • Activated by setting RIVE_SWIFT_COVERAGE=1 before pod install
  • Produces lcov and HTML reports filtered to only library Swift code (excludes Pods, nitrogen, etc.)

Usage

cd example/ios && RIVE_SWIFT_COVERAGE=1 bundle exec pod install && cd ../..
# build & run harness tests, then:
bash scripts/ios-coverage.sh

How it works

  • RNRive.podspec conditionally adds -profile-generate -profile-coverage-mapping to the RNRive pod
  • CoverageHelper.swift flushes LLVM profraw data via __llvm_profile_write_file on a 1s background timer, SIGTERM, and app lifecycle events
  • CoverageSetup.m bootstraps CoverageHelper via ObjC +load (no-op when coverage is disabled)
  • scripts/ios-coverage.sh merges per-process profraw files and generates reports via llvm-cov
  • Handles Xcode 26 debug.dylib (where code + coverage data lives in the dylib, not the main binary)

Test plan

  • Verified locally: 7/7 harness test suites pass, 28.9% line coverage across 34 Swift files
  • Non-coverage builds unaffected (pod install without env var compiles out all coverage code)

Opt-in with RIVE_SWIFT_COVERAGE=1 before pod install. Uses LLVM source-based coverage to measure which Swift code in ios/ gets exercised by harness tests. Run scripts/ios-coverage.sh after tests to extract and report coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant