Skip to content

Commit dc87ee7

Browse files
committed
Support index-import on all Xcode 16.x versions
Similar to: bazelbuild/rules_swift#1504 Part of #3160 This PR updates the index-import dependency to include both version 5.8 and 6.1 as the hash algorithm changed in Swift 6.1. To make this change backwards compatible we switch to the 5.8 version on Xcode 16.2 and under. Signed-off-by: Luis Padron <heyluispadron@gmail.com>
1 parent 601661d commit dc87ee7

29 files changed

+145
-32
lines changed

MODULE.bazel

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bazel_dep(name = "bazel_features", version = "1.3.0")
1010
bazel_dep(name = "bazel_skylib", version = "1.3.0")
1111
bazel_dep(
1212
name = "rules_swift",
13-
version = "1.18.0",
13+
version = "2.8.0",
1414
max_compatibility_level = 2,
1515
repo_name = "build_bazel_rules_swift",
1616
)
@@ -28,6 +28,7 @@ non_module_deps = use_extension("//xcodeproj:extensions.bzl", "non_module_deps")
2828
use_repo(
2929
non_module_deps,
3030
"rules_xcodeproj_index_import",
31+
"rules_xcodeproj_index_import_legacy",
3132
)
3233

3334
# Non-release dependencies
@@ -55,12 +56,6 @@ bazel_dep(
5556
repo_name = "io_bazel_stardoc",
5657
)
5758

58-
# Use newer versions of deps in development
59-
single_version_override(
60-
module_name = "rules_swift",
61-
version = "2.3.0",
62-
)
63-
6459
# Some of our deps are forcing a new stardoc on us, so pinning for now
6560
single_version_override(
6661
module_name = "stardoc",

examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/integration/test/fixtures/bwb_project_spec.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/rules_ios/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bazel_dep(
2020
)
2121
bazel_dep(
2222
name = "rules_ios",
23-
version = "5.5.1",
23+
version = "5.6.0",
2424
repo_name = "build_bazel_rules_ios",
2525
)
2626

examples/rules_ios/WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22

33
http_archive(
44
name = "build_bazel_rules_ios",
5-
sha256 = "c417b69639a737eb44e2af13309f1b00950d6d0c48f67c64ee36d3ea750f687e",
6-
url = "https://github.com/bazel-ios/rules_ios/releases/download/4.6.0/rules_ios.4.6.0.tar.gz",
5+
sha256 = "e0dbd18f1d7a48a4b98e97dbdc45dfc7f0b1cf902afe86c442614db17f560611",
6+
url = "https://github.com/bazel-ios/rules_ios/releases/download/5.6.0/rules_ios.5.6.0.tar.gz",
77
)
88

99
load(

examples/rules_ios/test/fixtures/bwb.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/rules_ios/test/fixtures/bwb_project_spec.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/internal/pbxproj_partials/write_pbxproj_prefix_tests.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def _write_pbxproj_prefix_test_impl(ctx):
5353
import_index_build_indexstores = (
5454
ctx.attr.import_index_build_indexstores
5555
),
56+
legacy_index_import = ctx.attr.legacy_index_import,
5657
index_import = ctx.attr.index_import,
5758
install_path = "a/project.xcodeproj",
5859
minimum_xcode_version = ctx.attr.minimum_xcode_version,
@@ -144,6 +145,7 @@ write_pbxproj_prefix_test = unittest.make(
144145
"default_xcode_configuration": attr.string(mandatory = True),
145146
"execution_root_file": attr.string(mandatory = True),
146147
"import_index_build_indexstores": attr.bool(mandatory = True),
148+
"legacy_index_import": attr.string(mandatory = True),
147149
"index_import": attr.string(mandatory = True),
148150
"minimum_xcode_version": attr.string(mandatory = True),
149151
"platforms": attr.string_list(mandatory = True),
@@ -180,6 +182,7 @@ def write_pbxproj_prefix_test_suite(name):
180182
default_xcode_configuration,
181183
execution_root_file,
182184
import_index_build_indexstores,
185+
legacy_index_import,
183186
index_import,
184187
minimum_xcode_version,
185188
platforms,
@@ -204,6 +207,7 @@ def write_pbxproj_prefix_test_suite(name):
204207
default_xcode_configuration = default_xcode_configuration,
205208
execution_root_file = execution_root_file,
206209
import_index_build_indexstores = import_index_build_indexstores,
210+
legacy_index_import = legacy_index_import,
207211
index_import = index_import,
208212
minimum_xcode_version = minimum_xcode_version,
209213
platforms = platforms,
@@ -233,6 +237,7 @@ def write_pbxproj_prefix_test_suite(name):
233237
default_xcode_configuration = "Debug",
234238
execution_root_file = "an/execution/root/file",
235239
import_index_build_indexstores = True,
240+
legacy_index_import = "some/path/to/legacy/index_import",
236241
index_import = "some/path/to/index_import",
237242
minimum_xcode_version = "14.2.1",
238243
platforms = [
@@ -262,6 +267,8 @@ def write_pbxproj_prefix_test_suite(name):
262267
"an/execution/root/file",
263268
# targetIdsFile
264269
"a/path/to/target_ids_list",
270+
# legacyIndexImport
271+
"some/path/to/legacy/index_import",
265272
# indexImport
266273
"some/path/to/index_import",
267274
# resolvedRepositoriesFile
@@ -296,6 +303,7 @@ def write_pbxproj_prefix_test_suite(name):
296303
default_xcode_configuration = "Release",
297304
execution_root_file = "an/execution/root/file",
298305
import_index_build_indexstores = False,
306+
legacy_index_import = "some/path/to/legacy/index_import",
299307
index_import = "some/path/to/index_import",
300308
platforms = [
301309
"MACOS",
@@ -328,6 +336,8 @@ def write_pbxproj_prefix_test_suite(name):
328336
"an/execution/root/file",
329337
# targetIdsFile
330338
"a/path/to/target_ids_list",
339+
# legacyIndexImport
340+
"some/path/to/legacy/index_import",
331341
# indexImport
332342
"some/path/to/index_import",
333343
# resolvedRepositoriesFile

tools/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ _XCSCHEMES = [
176176
# targetIdsFile
177177
"bazel-out/darwin_arm64-dbg/bin/external/_main~internal~rules_xcodeproj_generated/generator/tools/xcodeproj/xcodeproj_target_ids",
178178
# indexImport
179-
"bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import",
179+
"bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import_legacy/index-import",
180180
# resolvedRepositoriesFile
181181
"bazel-out/darwin_arm64-dbg/bin/external/_main~internal~rules_xcodeproj_generated/generator/tools/generators/xcodeproj/xcodeproj_pbxproj_partials/resolved_repositories",
182182
# minimumXcodeVersion

tools/generators/legacy/src/DTO/Project.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct Project: Equatable {
3939
var customXcodeSchemes: [XcodeScheme] = []
4040
let targetIdsFile: String
4141
let targetNameMode: TargetNameMode
42+
let legacyIndexImport: String
4243
let indexImport: String
4344
let preBuildScript: String?
4445
let postBuildScript: String?
@@ -61,7 +62,8 @@ extension Project: Decodable {
6162
case schemeAutogenerationMode = "s"
6263
case targetIdsFile = "T"
6364
case targetNameMode = "N"
64-
case indexImport = "i"
65+
case legacyIndexImport = "i"
66+
case indexImport = "j"
6567
case preBuildScript = "p"
6668
case postBuildScript = "P"
6769
}
@@ -107,6 +109,8 @@ extension Project: Decodable {
107109
TargetNameMode.self,
108110
forKey: .targetNameMode
109111
) ?? .auto
112+
legacyIndexImport = try container
113+
.decode(String.self, forKey: .legacyIndexImport)
110114
indexImport = try container
111115
.decode(String.self, forKey: .indexImport)
112116
preBuildScript = try container

tools/generators/legacy/src/Generator/CreateProject.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ extension Generator {
1212
forFixtures: Bool,
1313
project: Project,
1414
directories: Directories,
15+
legacyIndexImport: String,
1516
indexImport: String,
1617
minimumXcodeVersion: SemanticVersion
1718
) -> PBXProj {
@@ -94,6 +95,7 @@ $(SYMROOT)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9495
"IMPORT_INDEX_BUILD_INDEXSTORES": true,
9596
"INDEX_DATA_STORE_DIR": "$(INDEX_DATA_STORE_DIR)",
9697
"INDEX_FORCE_SCRIPT_EXECUTION": true,
98+
"LEGACY_INDEX_IMPORT": legacyIndexImport,
9799
"INDEX_IMPORT": indexImport,
98100
"INSTALL_PATH": "$(BAZEL_PACKAGE_BIN_DIR)/$(TARGET_NAME)/bin",
99101
"INTERNAL_DIR": """

tools/generators/legacy/src/Generator/Environment.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct Environment {
1212
_ forFixtures: Bool,
1313
_ project: Project,
1414
_ directories: Directories,
15+
_ legacyIndexImport: String,
1516
_ indexImport: String,
1617
_ minimumXcodeVersion: SemanticVersion
1718
) -> PBXProj

tools/generators/legacy/src/Generator/Generator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Generator {
5757
forFixtures,
5858
project,
5959
directories,
60+
project.legacyIndexImport,
6061
project.indexImport,
6162
project.minimumXcodeVersion
6263
)

tools/generators/legacy/test/CreateProjectTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ $(INDEXING_DEPLOYMENT_LOCATION__NO)
8686
"LD_OBJC_ABI_VERSION": "",
8787
"LD_DYLIB_INSTALL_NAME": "",
8888
"LD_RUNPATH_SEARCH_PATHS": "",
89+
"LEGACY_INDEX_IMPORT": "/tmp/legacy-index-import",
8990
"ONLY_ACTIVE_ARCH": true,
9091
"PROJECT_DIR": """
9192
/tmp/bazel-output-base/rules_xcodeproj/build_output_base/execroot/rules_xcodeproj
@@ -144,6 +145,7 @@ $(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)
144145
forFixtures: false,
145146
project: project,
146147
directories: directories,
148+
legacyIndexImport: project.legacyIndexImport,
147149
indexImport: project.indexImport,
148150
minimumXcodeVersion: project.minimumXcodeVersion
149151
)
@@ -215,6 +217,7 @@ $(BUILD_DIR)/$(BAZEL_PACKAGE_BIN_DIR)
215217
"GCC_OPTIMIZATION_LEVEL": "0",
216218
"LD": "$(BAZEL_INTEGRATION_DIR)/ld",
217219
"LDPLUSPLUS": "$(BAZEL_INTEGRATION_DIR)/ld",
220+
"LEGACY_INDEX_IMPORT": "/tmp/legacy-index-import",
218221
"LIBTOOL": "$(BAZEL_INTEGRATION_DIR)/libtool",
219222
"IMPORT_INDEX_BUILD_INDEXSTORES": true,
220223
"INDEX_DATA_STORE_DIR": "$(INDEX_DATA_STORE_DIR)",
@@ -286,6 +289,7 @@ $(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)
286289
forFixtures: false,
287290
project: project,
288291
directories: directories,
292+
legacyIndexImport: project.legacyIndexImport,
289293
indexImport: project.indexImport,
290294
minimumXcodeVersion: project.minimumXcodeVersion
291295
)

tools/generators/legacy/test/Fixtures.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum Fixtures {
4343
customXcodeSchemes: [],
4444
targetIdsFile: "/tmp/target_ids",
4545
targetNameMode: .auto,
46+
legacyIndexImport: "/tmp/legacy-index-import",
4647
indexImport: "/tmp/index-import",
4748
preBuildScript: "./pre-build.sh",
4849
postBuildScript: "./post-build.sh"

tools/generators/legacy/test/GeneratorTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ final class GeneratorTests: XCTestCase {
6666
customXcodeSchemes: [],
6767
targetIdsFile: "/tmp/target_ids",
6868
targetNameMode: .auto,
69+
legacyIndexImport: "/tmp/legacy-index-import",
6970
indexImport: "/tmp/index-import",
7071
preBuildScript: "./pre-build.sh",
7172
postBuildScript: "./post-build.sh"
@@ -265,6 +266,7 @@ final class GeneratorTests: XCTestCase {
265266
let buildMode: BuildMode
266267
let project: Project
267268
let directories: Directories
269+
let legacyIndexImport: String
268270
let indexImport: String
269271
let minimumXcodeVersion: SemanticVersion
270272
}
@@ -275,13 +277,15 @@ final class GeneratorTests: XCTestCase {
275277
_forFixtures _: Bool,
276278
project: Project,
277279
directories: Directories,
280+
legacyIndexImport: String,
278281
indexImport: String,
279282
minimumXcodeVersion: SemanticVersion
280283
) -> PBXProj {
281284
createProjectCalled.append(.init(
282285
buildMode: buildMode,
283286
project: project,
284287
directories: directories,
288+
legacyIndexImport: legacyIndexImport,
285289
indexImport: indexImport,
286290
minimumXcodeVersion: minimumXcodeVersion
287291
))
@@ -292,6 +296,7 @@ final class GeneratorTests: XCTestCase {
292296
buildMode: buildMode,
293297
project: project,
294298
directories: directories,
299+
legacyIndexImport: project.legacyIndexImport,
295300
indexImport: project.indexImport,
296301
minimumXcodeVersion: project.minimumXcodeVersion
297302
)]

tools/generators/pbxproj_prefix/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Here is an example output:
216216
GCC_OPTIMIZATION_LEVEL = 0;
217217
IMPORT_INDEX_BUILD_INDEXSTORES = YES;
218218
INDEX_DATA_STORE_DIR = "$(INDEX_DATA_STORE_DIR)";
219-
INDEX_IMPORT = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import";
219+
INDEX_IMPORT = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import_legacy";
220220
INDEX_FORCE_SCRIPT_EXECUTION = YES;
221221
INSTALL_PATH = "$(BAZEL_PACKAGE_BIN_DIR)/$(TARGET_NAME)/bin";
222222
INTERNAL_DIR = "$(PROJECT_FILE_PATH)/rules_xcodeproj";
@@ -276,7 +276,8 @@ Here is an example output:
276276
GCC_OPTIMIZATION_LEVEL = 0;
277277
IMPORT_INDEX_BUILD_INDEXSTORES = YES;
278278
INDEX_DATA_STORE_DIR = "$(INDEX_DATA_STORE_DIR)";
279-
INDEX_IMPORT = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import";
279+
INDEX_IMPORT_LEGACY = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import_legacy";
280+
INDEX_IMPORT = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import_5_8";
280281
INDEX_FORCE_SCRIPT_EXECUTION = YES;
281282
INSTALL_PATH = "$(BAZEL_PACKAGE_BIN_DIR)/$(TARGET_NAME)/bin";
282283
INTERNAL_DIR = "$(PROJECT_FILE_PATH)/rules_xcodeproj";

tools/generators/pbxproj_prefix/src/Generator/Arguments.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Path to a file that contains the absolute path to the Bazel execution root.
3030
@Argument(help: "Path to the target IDs list file.")
3131
var targetIdsFile: String
3232

33+
@Argument(help: "Path to the legacy index_import executable.")
34+
var legacyIndexImport: String
35+
3336
@Argument(help: "Path to the index_import executable.")
3437
var indexImport: String
3538

tools/generators/pbxproj_prefix/src/Generator/Environment.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extension Generator {
3232
let pbxProjectBuildSettings: (
3333
_ config: String,
3434
_ importIndexBuildIndexstores: Bool,
35+
_ legacyIndexImport: String,
3536
_ indexImport: String,
3637
_ indexingProjectDir: String,
3738
_ projectDir: String,

tools/generators/pbxproj_prefix/src/Generator/Generator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct Generator {
5151
/*config:*/ arguments.config,
5252
/*importIndexBuildIndexstores:*/ arguments
5353
.importIndexBuildIndexstores,
54+
/*legacyIndexImport:*/ arguments.legacyIndexImport,
5455
/*indexImport:*/ arguments.indexImport,
5556
/*indexingProjectDir:*/ environment.indexingProjectDir(
5657
/*projectDir:*/ projectDir

tools/generators/pbxproj_prefix/src/Generator/PBXProjectBuildSettings.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ extension Generator {
99
/// - config: The value to be used for the `BAZEL_CONFIG` build setting.
1010
/// - importIndexBuildIndexstores: Whether to import index build
1111
/// indexstores.
12+
/// - legacyIndexImport: The Bazel execution root relative path to the
13+
/// `index_import` (version 5.8) executable.
1214
/// - indexImport: The Bazel execution root relative path to the
13-
/// `index_import` executable.
15+
/// `index_import` (version 6.1+) executable.
1416
/// - indexingProjectDir: The value returned from
1517
/// `Generator.indexingProjectDir()`.
1618
/// - projectDir: The value returned from `Generator.projectDir()`.
@@ -20,6 +22,7 @@ extension Generator {
2022
static func pbxProjectBuildSettings(
2123
config: String,
2224
importIndexBuildIndexstores: Bool,
25+
legacyIndexImport: String,
2326
indexImport: String,
2427
indexingProjectDir: String,
2528
projectDir: String,
@@ -106,6 +109,12 @@ extension Generator {
106109
value: #""$(INDEX_DATA_STORE_DIR)""#
107110
),
108111
.init(key: "INDEX_FORCE_SCRIPT_EXECUTION", value: "YES"),
112+
.init(
113+
key: "LEGACY_INDEX_IMPORT",
114+
value: legacyIndexImport
115+
.executionRootBasedBuildSettingPath
116+
.pbxProjEscaped
117+
),
109118
.init(
110119
key: "INDEX_IMPORT",
111120
value: indexImport

0 commit comments

Comments
 (0)