MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
528 stars 86 forks source link

Bug: `index is 1, but sequence has 1 elements` `pbxproj_partials.bzl` #3092

Closed louwers closed 3 weeks ago

louwers commented 1 month ago

Description

After updating to rules_apple 3.9.2 I get the error below.

ERROR: /private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~~internal~rules_xcodeproj_generated/generator/platform/ios/xcodeproj/BUILD:12:10: Writing file external/rules_xcodeproj~~internal~rules_xcodeproj_generated/generator/platform/ios/xcodeproj/xcodeproj_pbxproj_partials/generated_folder_paths_file failed: 

/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl:534:40: Traceback (most recent call last):
        File "/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl", line 112, column 37, in _generated_folder
                return _generated_file_or_folder(
        File "/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl", line 82, column 24, in _generated_file_or_folder
                config = components[1]
Error: index out of range (index is 1, but sequence has 1 elements): 

/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl:534:40: Traceback (most recent call last):
        File "/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl", line 112, column 37, in _generated_folder
                return _generated_file_or_folder(
        File "/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl", line 82, column 24, in _generated_file_or_folder
                config = components[1]
Error: index out of range (index is 1, but sequence has 1 elements)
ERROR: /private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~~internal~rules_xcodeproj_generated/generator/platform/ios/xcodeproj/BUILD:12:10 Generating bazel-out/darwin_arm64-dbg/bin/external/rules_xcodeproj~~internal~rules_xcodeproj_generated/generator/platform/ios/xcodeproj/xcodeproj.project.pbxproj failed: 

/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl:534:40: Traceback (most recent call last):
        File "/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl", line 112, column 37, in _generated_folder
                return _generated_file_or_folder(
        File "/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl", line 82, column 24, in _generated_file_or_folder
                config = components[1]
Error: index out of range (index is 1, but sequence has 1 elements): 

/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl:534:40: Traceback (most recent call last):
        File "/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl", line 112, column 37, in _generated_folder
                return _generated_file_or_folder(
        File "/private/var/tmp/_bazel_bart/cebca26739145e4f0245c6428f550948/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj~/xcodeproj/internal/pbxproj_partials.bzl", line 82, column 24, in _generated_file_or_folder
                config = components[1]

Reproduction steps

git clone --recurse-submodules git@github.com:maplibre/maplibre-native.git
cd maplibre-native
# update rules_apple to 3.9.2 in MODULE.bazel
bazel run //platform/ios:xcodeproj --@rules_xcodeproj//xcodeproj:extra_common_flags="--//:renderer=metal"

Expected behavior

Xcode project is generated

rules_xcodeproj version

2.7.0

Xcode version

16

Bazel version

7.3.1

rules_apple version

3.9.2

rules_swift version

No response

Additional information

Krishna Ersson mentioned on Slack:

I also ran into this. For us, we weren’t able to generate a project when there was a data dependency on a custom rule that included a platform transition. I’m not sure if it was due to the transition or something else we were doing in our custom rule, though. I didn’t dive deep into it yet. My workaround was to use a bool_flag and config_setting that would get set to True when the rules_xcodeproj_generator config is active. Then I used a select to remove the data dependency so the Xcode project could be generated.

brentleyjones commented 3 weeks ago

https://github.com/bazelbuild/rules_apple/commit/91be02a886256b77770a67b9b42f4152bc209476 is the offending change in rules_apple. I'm looking into a fix.

brentleyjones commented 3 weeks ago

https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3098 should fix this. Can you give it a try?

louwers commented 3 weeks ago

Fixed 🥳