Hive Hive
Sign in

fix(cli): allow scheme code coverage targets from external projects

GitHub issue · Closed

Metadata
Source
tuist/tuist #11399
Updated
Jul 5, 2026
Domains
Generated projects Testing
Details

Resolves https://github.com/tuist/tuist/issues/11570

Summary

Allow codeCoverageTargets in project schemes to reference targets from other projects in the workspace, including SPM-generated projects.

Why

Xcode already supports this. In a scheme’s Test action, you can choose “Gather coverage for some targets” and select targets from anywhere in the workspace, including Swift Package Manager packages.

Tuist, however, was stricter and rejected these configurations during project linting:

  • Using a target name directly:

    The target ‘DesignSystem’ specified in Scheme code coverage targets list isn’t defined in the project.

  • Using an explicit TargetReference(projectPath:target:) pointing to another project:

    The target ‘DesignSystem’ specified in scheme ‘Scheme’ is not defined in the project named ‘X’. Consider using a workspace scheme instead to reference a target in another project.

As a result, tuist generate failed even though the configuration was perfectly valid in Xcode.

Root cause

This happened because three different pieces of logic interacted in an unexpected way:

  1. TestAction+ManifestMapper.swift resolves code coverage targets without an explicit projectPath to the local project.
  2. SchemeLinter.lintCodeCoverageTargets only validates targets that exist in the current project.
  3. SchemeLinter.projectSchemeCantReferenceRemoteTargets treats codeCoverageTargets as regular target dependencies and rejects references to targets outside the project.

At the same time, GraphLinter.lintSchemesUnknownTargets already validates scheme target references against the entire workspace graph and reports unresolved targets when needed.

Change

This PR makes two focused changes in SchemeLinter.swift:

  1. lintCodeCoverageTargets now only validates targets that belong to the current project. References to targets in other projects are left to the graph linter.
  2. projectSchemeCantReferenceRemoteTargets no longer considers codeCoverageTargets when checking for cross-project dependencies, since code coverage targets are coverage configuration rather than actual build dependencies.

This keeps the existing validation for local targets (including typo detection) while allowing valid cross-project coverage configurations that Xcode already supports.

User impact

Project schemes can now include code coverage targets from any project in the workspace, including SPM-generated projects, by using an explicit TargetReference.

Existing behavior remains unchanged for local targets, and invalid references are still caught by the workspace-level graph validation.

Flights

Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.

New Flights are paused Configure model inference, GitHub, and a sandbox provider to start another Flight. Existing results remain available below.
No Flights yet

Start a Flight and preserve its objective, outcome, and session here.

Comments
D
dogo Jun 27, 2026

Hi @fortmarek and @pepicrft 👋 I had a quick question about the PR review process. This PR has been open for a few days without any feedback, so I was wondering if there’s anything else I should do on my side (assign reviewers, add labels, etc.), or if it’s just waiting in the review queue.

Just want to make sure I’m following the expected contribution process correctly. Thanks! 🙏