Hive Hive
Sign in

Prune schemes with a test plan when generating the project with a focused subset of targets

GitHub issue · Open

Metadata
Source
tuist/tuist #6515
Updated
Jun 11, 2026
Domains
Generated projects
Details

What problem or need do you have?

My project spec includes a couple of extra schemes for the main iOS app that don’t work when I use tuist generate MyTarget to focus on a target. I would like for these schemes to not be generated when I’ve focused on a subset of targets.

Potential solution

If my Project.swift file has additional context about the conditions under which it is being used, I can write code that checks whether to supply the schemes.

One way to do this would be:

  1. Collect the context into a Codable struct:
public struct Context {
/// The path to this manifest file.
public let path: String
/// The list of targets whose sources should be included. All targets if empty.
public let sources: Set<String>
/// The configuration to generate for.
public let configuration: String?
}
  1. Populate an instance of the context and serialize it as JSON
  2. Include the serialized context as an argument in ManifestLoader.buildArguments(_:at:)
  3. Add a context property to ProjectDescription.Environment that reads the argument and decodes the context

This context would then be available in all the manifests.

Alternatively we could avoid using Codable and pass separate arguments instead. We’d parse them using ArgumentParser in Environment to populate a context struct.

macOS version

14.5

Tuist version

4.20.0

Xcode version

15.4

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
P
pepicrft Jul 15, 2024

@hiltonc, thanks a lot for reporting this one. Would you mind including a project where we can reproduce the issue and the steps to reproduce it? Once we have that, we can then provide what we believe is the most sensible solution that aligns with the principles that we’ve been embracing.

H
hiltonc Jul 21, 2024

In trying to create a minimal project to repro this I realized that you already have logic for pruning schemes 🎉. I think I ran into an edge case with my setup though. Here’s a minimal project to repro:

repro.zip

  1. tuist generate -> generates workspace with App, Framework1, and Custom Scheme schemes.

  2. tuist generate Framework1 -> generates workspace with Framework1 and Custom Scheme schemes. Prints warning about missing target in the scheme:

Loading and constructing the graph
It might take a while if the cache is empty
Using cache binaries for the following targets:
Generating workspace Workspace.xcworkspace
Generating project MainApp
Project generated.
Total time taken: 0.624s
The following warnings need attention:
· Cannot find targets App (App) defined in Custom Scheme

I would expect this scheme to be pruned because App is not included in the focused subset of targets.

H
hiltonc Aug 9, 2024

It looks like what is happening is that the targets are getting pruned, but the scheme is not because it has a test plan. There’s no logic to either (a) prune targets from a test plan, or simpler (b) examine the targets in a test plan and prune the scheme if any of them are pruned.