MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
502 stars 76 forks source link

Bug: The associated extra file, owned by multiple targets, is not added to the project #3021

Closed CognitiveDisson closed 1 month ago

CognitiveDisson commented 2 months ago

Description

If a file is owned by multiple targets but only one target is added to the project, the file will not be included in the project, as it will only be associated with one of the targets. You can reproduce this on an example project like this:

ASSOCIATED_EXTRA_FILES = {
    "//Lib": ["//Lib:README.md"],
    "//Lib:ios_Lib": ["//Lib:README.md"],
...

( examples/integration/xcodeproj_targets.bzl )

Screenshot 2024-05-03 at 17 02 20

Reproduction steps

  1. Edit the examples/integration/xcodeproj_targets.bzl file as previously instructed.
  2. Run the command bazel run --config=cache //:xcodeproj-incremental-bazel-sim_arm64.
  3. Open the project.
  4. Note that the Lib/README.md file is not included in the project.

Expected behavior

A file should be included in the project if at least one associated target in the project. If this is difficult to achieve, will be nice to have a warning for this case.

rules_xcodeproj version

a6640cabc5dd30492dffe0c5fb3da9b114796dba

Xcode version

15.2

Bazel version

7.1

rules_apple version

No response

rules_swift version

No response

Additional information

It seems to be related to how the owned_extra_files value is created in xcodeproj/internal/xcodeproj_macro.bzl. However, the problem is that the xcodeproj rule expects attr.label_keyed_string_dict and we need something like labed_keyed_list_dict, which doesn't exist in Bazel.