Skip to content

Commit b579b6c

Browse files
authored
Support index-import on all Xcode 16.x versions (#3162)
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 <[email protected]>
1 parent 601661d commit b579b6c

29 files changed

+145
-30
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_legacy_index_import",
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
@@ -55,6 +55,7 @@ def _write_pbxproj_prefix_test_impl(ctx):
5555
),
5656
index_import = ctx.attr.index_import,
5757
install_path = "a/project.xcodeproj",
58+
legacy_index_import = ctx.attr.legacy_index_import,
5859
minimum_xcode_version = ctx.attr.minimum_xcode_version,
5960
platforms = ctx.attr.platforms,
6061
post_build_script = ctx.attr.post_build_script,
@@ -145,6 +146,7 @@ write_pbxproj_prefix_test = unittest.make(
145146
"execution_root_file": attr.string(mandatory = True),
146147
"import_index_build_indexstores": attr.bool(mandatory = True),
147148
"index_import": attr.string(mandatory = True),
149+
"legacy_index_import": attr.string(mandatory = True),
148150
"minimum_xcode_version": attr.string(mandatory = True),
149151
"platforms": attr.string_list(mandatory = True),
150152
"post_build_script": attr.string(),
@@ -181,6 +183,7 @@ def write_pbxproj_prefix_test_suite(name):
181183
execution_root_file,
182184
import_index_build_indexstores,
183185
index_import,
186+
legacy_index_import,
184187
minimum_xcode_version,
185188
platforms,
186189
post_build_script = None,
@@ -205,6 +208,7 @@ def write_pbxproj_prefix_test_suite(name):
205208
execution_root_file = execution_root_file,
206209
import_index_build_indexstores = import_index_build_indexstores,
207210
index_import = index_import,
211+
legacy_index_import = legacy_index_import,
208212
minimum_xcode_version = minimum_xcode_version,
209213
platforms = platforms,
210214
post_build_script = post_build_script,
@@ -234,6 +238,7 @@ def write_pbxproj_prefix_test_suite(name):
234238
execution_root_file = "an/execution/root/file",
235239
import_index_build_indexstores = True,
236240
index_import = "some/path/to/index_import",
241+
legacy_index_import = "some/path/to/legacy/index_import",
237242
minimum_xcode_version = "14.2.1",
238243
platforms = [
239244
"MACOS",
@@ -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
@@ -297,6 +304,7 @@ def write_pbxproj_prefix_test_suite(name):
297304
execution_root_file = "an/execution/root/file",
298305
import_index_build_indexstores = False,
299306
index_import = "some/path/to/index_import",
307+
legacy_index_import = "some/path/to/legacy/index_import",
300308
platforms = [
301309
"MACOS",
302310
"IOS_DEVICE",
@@ -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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ _XCSCHEMES = [
175175
"bazel-output-base/rules_xcodeproj.noindex/build_output_base/execroot/_main/bazel-out/darwin_arm64-dbg/bin/external/_main~internal~rules_xcodeproj_generated/generator/tools/xcodeproj/xcodeproj_execution_root_file",
176176
# targetIdsFile
177177
"bazel-out/darwin_arm64-dbg/bin/external/_main~internal~rules_xcodeproj_generated/generator/tools/xcodeproj/xcodeproj_target_ids",
178+
# legacyIndexImport
179+
"bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_legacy_index_import/index-import",
178180
# indexImport
179181
"bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import",
180182
# resolvedRepositoriesFile

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 {
@@ -104,6 +105,7 @@ $(PROJECT_FILE_PATH)/\(directories.internalDirectoryName)
104105
// We don't want Xcode to set any search paths, since we set them in
105106
// `link.params`
106107
"LD_RUNPATH_SEARCH_PATHS": "",
108+
"LEGACY_INDEX_IMPORT": legacyIndexImport,
107109
"ONLY_ACTIVE_ARCH": true,
108110
"PROJECT_DIR": absoluteProjectDirPath,
109111
"RULES_XCODEPROJ_BUILD_MODE": buildMode.rawValue,

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: 2 additions & 1 deletion
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";
@@ -285,6 +285,7 @@ Here is an example output:
285285
LD_DYLIB_INSTALL_NAME = "";
286286
LD_OBJC_ABI_VERSION = "";
287287
LD_RUNPATH_SEARCH_PATHS = "";
288+
LEGACY_INDEX_IMPORT = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import_legacy";
288289
LIBTOOL = "$(BAZEL_INTEGRATION_DIR)/libtool";
289290
ONLY_ACTIVE_ARCH = YES;
290291
PROJECT_DIR = "/tmp/workspace/bazel-output-base/rules_xcodeproj.noindex/build_output_base/execroot/_main";

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,
@@ -123,6 +126,12 @@ extension Generator {
123126
.init(key: "LD_DYLIB_INSTALL_NAME", value: #""""#),
124127
.init(key: "LD_OBJC_ABI_VERSION", value: #""""#),
125128
.init(key: "LD_RUNPATH_SEARCH_PATHS", value: #""""#),
129+
.init(
130+
key: "LEGACY_INDEX_IMPORT",
131+
value: legacyIndexImport
132+
.executionRootBasedBuildSettingPath
133+
.pbxProjEscaped
134+
),
126135
.init(key: "ONLY_ACTIVE_ARCH", value: "YES"),
127136
.init(
128137
key: "PROJECT_DIR",

0 commit comments

Comments
 (0)