MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
514 stars 81 forks source link

Bug: "Make" variable expansion in the `env` of test bundles does not work. #3056

Open aaronsky opened 1 month ago

aaronsky commented 1 month ago

Description

"Make" variable expansion support was added to rules_apple in this commit and shipped with version 3.6.0. This allows for Starlark like this to work without requiring a --test_env in a bazelrc.

string_flag(
    name = "my_make_var",
    build_setting_default = "",
    make_variable = "MY_MAKE_VAR",
)

objc_library(
    name = "make_var_unit_test_lib",
    srcs = ["make_var_unit_test.m"],
)

ios_unit_test(
    name = "MakeVarUnitTest",
    deps = [":make_var_unit_test_lib"],
    env = {
        "MY_MAKE_VAR": "$(MY_MAKE_VAR)",
    },
    toolchains = [":my_make_var"],
)

This works well enough when building with Bazel's CLI. With Xcode, however, the scheme that is generated for this test produces the uninterpolated value for the env. Is this possible to support in the xcodeproj generator?

Reproduction steps

  1. Create a string_flag with a make_variable value
  2. Create a *_unit_test that takes the string_flag as one of its toolchains and expands the value in its env attr.
  3. Create an xcodeproj that takes the unit test as a top-level target.
  4. Generate the xcodeproj.

Expected behavior

Observe that the generated scheme has the literal $(MY_MAKE_VAR) (or whatever your make_variable was named), and not the interpolated value from bazelrc or even the default value.

rules_xcodeproj version

2.5.1

Xcode version

15F31d

Bazel version

7.2.1

rules_apple version

3.6.0

rules_swift version

2.0.0

Additional information

I am using incremental generation and automatic scheme generation.