MobileNativeFoundation / rules_xcodeproj

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

Fix error with an empty or None xcscheme env value #2935

Closed CognitiveDisson closed 5 months ago

CognitiveDisson commented 5 months ago

If the xcscheme env is set to 'None' or an empty dictionary, the project generation will fail with this error:

ERROR: /Users/username/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~override~internal~rules_xcodeproj_generated/generator/xcodeproj-incremental-bazel-sim_arm64/BUILD:12:10: in xcodeproj rule @@rules_xcodeproj~override~internal~rules_xcodeproj_generated//generator/xcodeproj-incremental-bazel-sim_arm64:xcodeproj-incremental-bazel-sim_arm64:
Traceback (most recent call last):
    File "/Users/username/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~override/xcodeproj/internal/xcodeproj_incremental_rule.bzl", line 637, column 53, in _xcodeproj_incremental_impl
        (xcschemes, xcschememanagement) = _write_schemes(
    File "/Users/username/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~override/xcodeproj/internal/xcodeproj_incremental_rule.bzl", line 477, column 53, in _write_schemes
        xcscheme_infos = xcscheme_infos_module.from_json(
    File "/Users/username/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~override/xcodeproj/internal/xcschemes/xcscheme_infos.bzl", line 707, column 31, in _from_json
        _scheme_info_from_dict(
    File "/Users/username/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~override/xcodeproj/internal/xcschemes/xcscheme_infos.bzl", line 694, column 36, in _scheme_info_from_dict
        test = _test_info_from_dict(
    File "/Users/username/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~override/xcodeproj/internal/xcschemes/xcscheme_infos.bzl", line 610, column 35, in _test_info_from_dict
        env = _env_infos_from_dict(test["env"]),
    File "/Users/username/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~override/xcodeproj/internal/xcschemes/xcscheme_infos.bzl", line 263, column 30, in _env_infos_from_dict
        for key, value in env.items()
Error: 'list' value has no field or method 'items'

You can reproduce this in examples by setting the value for 'env' to an empty dictionary, for example, like this:

        test = xcschemes.test(
            env = {
                # "IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR": "TRUE",
            },