iOS Code Coverage Setup
Workflow
Inspect the existing CI path before editing:
codemagic.yaml,.github/workflows/*, or other CI config.fastlane/Fastfile,Gemfile,Package.resolved, and test scheme settings.- README badge URLs and any existing
coverage-badgebranch or GitHub Pages setup. - For failed builds, inspect the exact failed step logs before choosing a fix.
Prefer shared lanes when the project already uses or should use common iOS CI lanes. In Fastlane, import the shared lane repo and call shared coverage lanes from CI rather than copying large lane bodies into app repos.
Keep coverage generation in the required test workflow unless the user explicitly wants a separate job. For Codemagic, the robust pattern is:
- Required PR workflow runs unit tests with code coverage enabled.
- The same workflow generates the coverage report and PR comment.
- The same workflow also runs on pushes to the default integration branch.
- Badge publishing is skipped on PR branches and only writes badge artifacts from the integration branch.
Do not make CI push README commits directly to a protected branch. Use a checked-in README badge URL that points to a badge artifact, then let CI update only the badge artifact branch/path.
For private GitHub repos, do not use private
raw.githubusercontent.combadge URLs in README. GitHub README image fetchers often cannot authenticate. Prefer GitHub Pages from a badge branch, or another public static badge host.Validate locally before pushing:
- Parse YAML with alias support.
- Check embedded shell scripts with
bash -n. - Run
git diff --check. - Verify the badge URL returns
HTTP 200. - Run the repo-required review skill before committing if repo instructions require it.
Implementation Reference
Read codemagic-fastlane-pattern.md when implementing or debugging the concrete Codemagic/Fastlane/GitHub Pages setup.
Review Checks
Before declaring done, verify:
- PR builds cannot overwrite shared badge artifacts.
- Default-branch push builds do not require PR-only env vars such as
CM_PULL_REQUEST_NUMBER. - Badge publishing does not try to push README changes to a protected branch.
- The README badge URL is public and renders without authentication.
- The required CI check name remains stable if branch protection depends on it.