Skip to content

Feature Request: Support multiple values for the same environment variable in custom schemes #3342

Open

Description

@antonsergeevamo

Motivation

Xcode's scheme editor allows several rows with the same environment variable name, each with its own checkbox. This is a convenient way to keep a menu of known values, for example OS_ACTIVITY_MODE rows for disable, info, and debug, or CFNETWORK_DIAGNOSTICS rows for 1, 2, and 3, with one of them checked.

Custom schemes cannot express this, because env in xcschemes.run, xcschemes.profile, and xcschemes.test is a dict, so each key carries exactly one value. Rows added by hand in Xcode are lost on the next regeneration.

Proposal

Allow an env value to also be a list of xcschemes.env_value entries. Each entry becomes one row for that key, in list order:

xcschemes.run(
    env = {
        "OS_ACTIVITY_MODE": [
            xcschemes.env_value("disable"),
            xcschemes.env_value("info", enabled = False),
            xcschemes.env_value("debug", enabled = False),
        ],
    },
)

This generates three OS_ACTIVITY_MODE rows with only disable enabled. Single values and "inherit" keep their current behavior.

Implementation

Only Starlark changes are needed: _env_infos_from_dict in xcscheme_infos.bzl would produce a list of values per key, and _add_env in xcschemes_execution.bzl would write the flattened count and one triple per entry. The generator already parses custom scheme variables into an array and writes them in order without deduplicating by key.

I am happy to open a pull request with the change, docs, tests, and a CHANGELOG entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions