@@ -35,6 +35,7 @@ load(":platforms.bzl", "platforms")
3535load (":project_options.bzl" , "project_options_to_dto" )
3636load (":resource_target.bzl" , "process_resource_bundles" )
3737load (":target_id.bzl" , "write_target_ids_list" )
38+ load (":xcode_version_util.bzl" , "is_xcode_at_least_version" )
3839load (":xcodeprojinfo.bzl" , "XcodeProjInfo" )
3940
4041# Utility
@@ -1584,6 +1585,18 @@ configurations: {}""".format(", ".join(xcode_configurations)))
15841585 if s .id in targets
15851586 ]
15861587
1588+ # TODO: Remove once we drop support for Xcode 16.x.
1589+ # We set a private environment variable when using a version older than Xcode 16.3
1590+ # which comes with Swift 6.1 which changes the hash algorithm for the index-import tool.
1591+ # When using an older version we switch to the older version of index-import.
1592+ xcode_toolchain_config = ctx .attr ._xcode_config [apple_common .XcodeVersionConfig ]
1593+ if not is_xcode_at_least_version (xcode_toolchain_config , "16.3" ):
1594+ index_import = ctx .executable ._index_import_5_8
1595+ index_import_files_to_run = ctx .attr ._index_import_5_8 [DefaultInfo ].files_to_run
1596+ else :
1597+ index_import = ctx .executable ._index_import_6_1
1598+ index_import_files_to_run = ctx .attr ._index_import_6_1 [DefaultInfo ].files_to_run
1599+
15871600 spec_files = _write_spec (
15881601 actions = actions ,
15891602 args = args ,
@@ -1592,7 +1605,7 @@ configurations: {}""".format(", ".join(xcode_configurations)))
15921605 envs = envs ,
15931606 extra_files = extra_files ,
15941607 extra_folders = extra_folders ,
1595- index_import = ctx . executable . _index_import ,
1608+ index_import = index_import ,
15961609 infos = infos ,
15971610 is_fixture = is_fixture ,
15981611 minimum_xcode_version = minimum_xcode_version ,
@@ -1735,7 +1748,7 @@ done
17351748 execution_root_file = execution_root_file ,
17361749 extension_point_identifiers_file = extension_point_identifiers_file ,
17371750 generator = ctx .attr ._generator [DefaultInfo ].files_to_run ,
1738- index_import = ctx . attr . _index_import [ DefaultInfo ]. files_to_run ,
1751+ index_import = index_import_files_to_run ,
17391752 install_path = install_path ,
17401753 is_fixture = is_fixture ,
17411754 name = name ,
@@ -1760,7 +1773,7 @@ done
17601773 input_files_output_groups = input_files .to_output_groups_fields (
17611774 inputs = inputs ,
17621775 additional_bwx_generated = additional_bwx_generated ,
1763- index_import = ctx . executable . _index_import ,
1776+ index_import = index_import ,
17641777 )
17651778 output_files_output_groups = {}
17661779 all_targets_files = [
@@ -1773,7 +1786,7 @@ done
17731786 output_files_output_groups = output_files .to_output_groups_fields (
17741787 outputs = provider_outputs ,
17751788 additional_bwb_outputs = additional_bwb_outputs ,
1776- index_import = ctx . executable . _index_import ,
1789+ index_import = index_import ,
17771790 )
17781791 all_targets_files = [output_files_output_groups ["all_b" ]]
17791792
@@ -1891,9 +1904,17 @@ def _xcodeproj_legacy_attrs(
18911904 default = Label ("//tools/generators/legacy:universal_generator" ),
18921905 executable = True ,
18931906 ),
1894- "_index_import" : attr .label (
1907+ # TODO: we must depend on two versions of index-import to support backwards
1908+ # compatibility between Xcode 16.3+ and older versions, we can remove the older
1909+ # version once we drop support for Xcode 16.x.
1910+ "_index_import_5_8" : attr .label (
1911+ cfg = "exec" ,
1912+ default = Label ("@rules_xcodeproj_index_import_5_8//:index_import" ),
1913+ executable = True ,
1914+ ),
1915+ "_index_import_6_1" : attr .label (
18951916 cfg = "exec" ,
1896- default = Label ("@rules_xcodeproj_index_import //:index_import" ),
1917+ default = Label ("@rules_xcodeproj_index_import_6_1 //:index_import" ),
18971918 executable = True ,
18981919 ),
18991920 "_installer_template" : attr .label (
0 commit comments