Skip to content

Support index-import on all Xcode 16.x versions #3162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bazel_dep(name = "bazel_features", version = "1.3.0")
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(
name = "rules_swift",
version = "1.18.0",
version = "2.8.0",
max_compatibility_level = 2,
repo_name = "build_bazel_rules_swift",
)
Expand All @@ -28,6 +28,7 @@ non_module_deps = use_extension("//xcodeproj:extensions.bzl", "non_module_deps")
use_repo(
non_module_deps,
"rules_xcodeproj_index_import",
"rules_xcodeproj_legacy_index_import",
)

# Non-release dependencies
Expand Down Expand Up @@ -55,12 +56,6 @@ bazel_dep(
repo_name = "io_bazel_stardoc",
)

# Use newer versions of deps in development
single_version_override(
module_name = "rules_swift",
version = "2.3.0",
)

# Some of our deps are forcing a new stardoc on us, so pinning for now
single_version_override(
module_name = "stardoc",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/integration/test/fixtures/bwb_project_spec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/rules_ios/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bazel_dep(
)
bazel_dep(
name = "rules_ios",
version = "5.5.1",
version = "5.6.0",
repo_name = "build_bazel_rules_ios",
)

Expand Down
4 changes: 2 additions & 2 deletions examples/rules_ios/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

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

load(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/rules_ios/test/fixtures/bwb_project_spec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/internal/pbxproj_partials/write_pbxproj_prefix_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def _write_pbxproj_prefix_test_impl(ctx):
),
index_import = ctx.attr.index_import,
install_path = "a/project.xcodeproj",
legacy_index_import = ctx.attr.legacy_index_import,
minimum_xcode_version = ctx.attr.minimum_xcode_version,
platforms = ctx.attr.platforms,
post_build_script = ctx.attr.post_build_script,
Expand Down Expand Up @@ -145,6 +146,7 @@ write_pbxproj_prefix_test = unittest.make(
"execution_root_file": attr.string(mandatory = True),
"import_index_build_indexstores": attr.bool(mandatory = True),
"index_import": attr.string(mandatory = True),
"legacy_index_import": attr.string(mandatory = True),
"minimum_xcode_version": attr.string(mandatory = True),
"platforms": attr.string_list(mandatory = True),
"post_build_script": attr.string(),
Expand Down Expand Up @@ -181,6 +183,7 @@ def write_pbxproj_prefix_test_suite(name):
execution_root_file,
import_index_build_indexstores,
index_import,
legacy_index_import,
minimum_xcode_version,
platforms,
post_build_script = None,
Expand All @@ -205,6 +208,7 @@ def write_pbxproj_prefix_test_suite(name):
execution_root_file = execution_root_file,
import_index_build_indexstores = import_index_build_indexstores,
index_import = index_import,
legacy_index_import = legacy_index_import,
minimum_xcode_version = minimum_xcode_version,
platforms = platforms,
post_build_script = post_build_script,
Expand Down Expand Up @@ -234,6 +238,7 @@ def write_pbxproj_prefix_test_suite(name):
execution_root_file = "an/execution/root/file",
import_index_build_indexstores = True,
index_import = "some/path/to/index_import",
legacy_index_import = "some/path/to/legacy/index_import",
minimum_xcode_version = "14.2.1",
platforms = [
"MACOS",
Expand Down Expand Up @@ -262,6 +267,8 @@ def write_pbxproj_prefix_test_suite(name):
"an/execution/root/file",
# targetIdsFile
"a/path/to/target_ids_list",
# legacyIndexImport
"some/path/to/legacy/index_import",
# indexImport
"some/path/to/index_import",
# resolvedRepositoriesFile
Expand Down Expand Up @@ -297,6 +304,7 @@ def write_pbxproj_prefix_test_suite(name):
execution_root_file = "an/execution/root/file",
import_index_build_indexstores = False,
index_import = "some/path/to/index_import",
legacy_index_import = "some/path/to/legacy/index_import",
platforms = [
"MACOS",
"IOS_DEVICE",
Expand Down Expand Up @@ -328,6 +336,8 @@ def write_pbxproj_prefix_test_suite(name):
"an/execution/root/file",
# targetIdsFile
"a/path/to/target_ids_list",
# legacyIndexImport
"some/path/to/legacy/index_import",
# indexImport
"some/path/to/index_import",
# resolvedRepositoriesFile
Expand Down
2 changes: 2 additions & 0 deletions tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ _XCSCHEMES = [
"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",
# targetIdsFile
"bazel-out/darwin_arm64-dbg/bin/external/_main~internal~rules_xcodeproj_generated/generator/tools/xcodeproj/xcodeproj_target_ids",
# legacyIndexImport
"bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_legacy_index_import/index-import",
# indexImport
"bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import",
# resolvedRepositoriesFile
Expand Down
6 changes: 5 additions & 1 deletion tools/generators/legacy/src/DTO/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct Project: Equatable {
var customXcodeSchemes: [XcodeScheme] = []
let targetIdsFile: String
let targetNameMode: TargetNameMode
let legacyIndexImport: String
let indexImport: String
let preBuildScript: String?
let postBuildScript: String?
Expand All @@ -61,7 +62,8 @@ extension Project: Decodable {
case schemeAutogenerationMode = "s"
case targetIdsFile = "T"
case targetNameMode = "N"
case indexImport = "i"
case legacyIndexImport = "i"
case indexImport = "j"
case preBuildScript = "p"
case postBuildScript = "P"
}
Expand Down Expand Up @@ -107,6 +109,8 @@ extension Project: Decodable {
TargetNameMode.self,
forKey: .targetNameMode
) ?? .auto
legacyIndexImport = try container
.decode(String.self, forKey: .legacyIndexImport)
indexImport = try container
.decode(String.self, forKey: .indexImport)
preBuildScript = try container
Expand Down
2 changes: 2 additions & 0 deletions tools/generators/legacy/src/Generator/CreateProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension Generator {
forFixtures: Bool,
project: Project,
directories: Directories,
legacyIndexImport: String,
indexImport: String,
minimumXcodeVersion: SemanticVersion
) -> PBXProj {
Expand Down Expand Up @@ -104,6 +105,7 @@ $(PROJECT_FILE_PATH)/\(directories.internalDirectoryName)
// We don't want Xcode to set any search paths, since we set them in
// `link.params`
"LD_RUNPATH_SEARCH_PATHS": "",
"LEGACY_INDEX_IMPORT": legacyIndexImport,
"ONLY_ACTIVE_ARCH": true,
"PROJECT_DIR": absoluteProjectDirPath,
"RULES_XCODEPROJ_BUILD_MODE": buildMode.rawValue,
Expand Down
1 change: 1 addition & 0 deletions tools/generators/legacy/src/Generator/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct Environment {
_ forFixtures: Bool,
_ project: Project,
_ directories: Directories,
_ legacyIndexImport: String,
_ indexImport: String,
_ minimumXcodeVersion: SemanticVersion
) -> PBXProj
Expand Down
1 change: 1 addition & 0 deletions tools/generators/legacy/src/Generator/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Generator {
forFixtures,
project,
directories,
project.legacyIndexImport,
project.indexImport,
project.minimumXcodeVersion
)
Expand Down
4 changes: 4 additions & 0 deletions tools/generators/legacy/test/CreateProjectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ $(INDEXING_DEPLOYMENT_LOCATION__NO)
"LD_OBJC_ABI_VERSION": "",
"LD_DYLIB_INSTALL_NAME": "",
"LD_RUNPATH_SEARCH_PATHS": "",
"LEGACY_INDEX_IMPORT": "/tmp/legacy-index-import",
"ONLY_ACTIVE_ARCH": true,
"PROJECT_DIR": """
/tmp/bazel-output-base/rules_xcodeproj/build_output_base/execroot/rules_xcodeproj
Expand Down Expand Up @@ -144,6 +145,7 @@ $(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)
forFixtures: false,
project: project,
directories: directories,
legacyIndexImport: project.legacyIndexImport,
indexImport: project.indexImport,
minimumXcodeVersion: project.minimumXcodeVersion
)
Expand Down Expand Up @@ -215,6 +217,7 @@ $(BUILD_DIR)/$(BAZEL_PACKAGE_BIN_DIR)
"GCC_OPTIMIZATION_LEVEL": "0",
"LD": "$(BAZEL_INTEGRATION_DIR)/ld",
"LDPLUSPLUS": "$(BAZEL_INTEGRATION_DIR)/ld",
"LEGACY_INDEX_IMPORT": "/tmp/legacy-index-import",
"LIBTOOL": "$(BAZEL_INTEGRATION_DIR)/libtool",
"IMPORT_INDEX_BUILD_INDEXSTORES": true,
"INDEX_DATA_STORE_DIR": "$(INDEX_DATA_STORE_DIR)",
Expand Down Expand Up @@ -286,6 +289,7 @@ $(PROJECT_TEMP_DIR)/$(BAZEL_PACKAGE_BIN_DIR)/$(COMPILE_TARGET_NAME)
forFixtures: false,
project: project,
directories: directories,
legacyIndexImport: project.legacyIndexImport,
indexImport: project.indexImport,
minimumXcodeVersion: project.minimumXcodeVersion
)
Expand Down
1 change: 1 addition & 0 deletions tools/generators/legacy/test/Fixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum Fixtures {
customXcodeSchemes: [],
targetIdsFile: "/tmp/target_ids",
targetNameMode: .auto,
legacyIndexImport: "/tmp/legacy-index-import",
indexImport: "/tmp/index-import",
preBuildScript: "./pre-build.sh",
postBuildScript: "./post-build.sh"
Expand Down
5 changes: 5 additions & 0 deletions tools/generators/legacy/test/GeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ final class GeneratorTests: XCTestCase {
customXcodeSchemes: [],
targetIdsFile: "/tmp/target_ids",
targetNameMode: .auto,
legacyIndexImport: "/tmp/legacy-index-import",
indexImport: "/tmp/index-import",
preBuildScript: "./pre-build.sh",
postBuildScript: "./post-build.sh"
Expand Down Expand Up @@ -265,6 +266,7 @@ final class GeneratorTests: XCTestCase {
let buildMode: BuildMode
let project: Project
let directories: Directories
let legacyIndexImport: String
let indexImport: String
let minimumXcodeVersion: SemanticVersion
}
Expand All @@ -275,13 +277,15 @@ final class GeneratorTests: XCTestCase {
_forFixtures _: Bool,
project: Project,
directories: Directories,
legacyIndexImport: String,
indexImport: String,
minimumXcodeVersion: SemanticVersion
) -> PBXProj {
createProjectCalled.append(.init(
buildMode: buildMode,
project: project,
directories: directories,
legacyIndexImport: legacyIndexImport,
indexImport: indexImport,
minimumXcodeVersion: minimumXcodeVersion
))
Expand All @@ -292,6 +296,7 @@ final class GeneratorTests: XCTestCase {
buildMode: buildMode,
project: project,
directories: directories,
legacyIndexImport: project.legacyIndexImport,
indexImport: project.indexImport,
minimumXcodeVersion: project.minimumXcodeVersion
)]
Expand Down
3 changes: 2 additions & 1 deletion tools/generators/pbxproj_prefix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Here is an example output:
GCC_OPTIMIZATION_LEVEL = 0;
IMPORT_INDEX_BUILD_INDEXSTORES = YES;
INDEX_DATA_STORE_DIR = "$(INDEX_DATA_STORE_DIR)";
INDEX_IMPORT = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import";
INDEX_IMPORT = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import_legacy";
INDEX_FORCE_SCRIPT_EXECUTION = YES;
INSTALL_PATH = "$(BAZEL_PACKAGE_BIN_DIR)/$(TARGET_NAME)/bin";
INTERNAL_DIR = "$(PROJECT_FILE_PATH)/rules_xcodeproj";
Expand Down Expand Up @@ -285,6 +285,7 @@ Here is an example output:
LD_DYLIB_INSTALL_NAME = "";
LD_OBJC_ABI_VERSION = "";
LD_RUNPATH_SEARCH_PATHS = "";
LEGACY_INDEX_IMPORT = "$(BAZEL_OUT)/darwin_arm64-opt-exec-2B5CBBC6/bin/external/_main~non_module_deps~rules_xcodeproj_index_import/index-import_legacy";
LIBTOOL = "$(BAZEL_INTEGRATION_DIR)/libtool";
ONLY_ACTIVE_ARCH = YES;
PROJECT_DIR = "/tmp/workspace/bazel-output-base/rules_xcodeproj.noindex/build_output_base/execroot/_main";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Path to a file that contains the absolute path to the Bazel execution root.
@Argument(help: "Path to the target IDs list file.")
var targetIdsFile: String

@Argument(help: "Path to the legacy index_import executable.")
var legacyIndexImport: String

@Argument(help: "Path to the index_import executable.")
var indexImport: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extension Generator {
let pbxProjectBuildSettings: (
_ config: String,
_ importIndexBuildIndexstores: Bool,
_ legacyIndexImport: String,
_ indexImport: String,
_ indexingProjectDir: String,
_ projectDir: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct Generator {
/*config:*/ arguments.config,
/*importIndexBuildIndexstores:*/ arguments
.importIndexBuildIndexstores,
/*legacyIndexImport:*/ arguments.legacyIndexImport,
/*indexImport:*/ arguments.indexImport,
/*indexingProjectDir:*/ environment.indexingProjectDir(
/*projectDir:*/ projectDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ extension Generator {
/// - config: The value to be used for the `BAZEL_CONFIG` build setting.
/// - importIndexBuildIndexstores: Whether to import index build
/// indexstores.
/// - legacyIndexImport: The Bazel execution root relative path to the
/// `index_import` (version 5.8) executable.
/// - indexImport: The Bazel execution root relative path to the
/// `index_import` executable.
/// `index_import` (version 6.1+) executable.
/// - indexingProjectDir: The value returned from
/// `Generator.indexingProjectDir()`.
/// - projectDir: The value returned from `Generator.projectDir()`.
Expand All @@ -20,6 +22,7 @@ extension Generator {
static func pbxProjectBuildSettings(
config: String,
importIndexBuildIndexstores: Bool,
legacyIndexImport: String,
indexImport: String,
indexingProjectDir: String,
projectDir: String,
Expand Down Expand Up @@ -123,6 +126,12 @@ extension Generator {
.init(key: "LD_DYLIB_INSTALL_NAME", value: #""""#),
.init(key: "LD_OBJC_ABI_VERSION", value: #""""#),
.init(key: "LD_RUNPATH_SEARCH_PATHS", value: #""""#),
.init(
key: "LEGACY_INDEX_IMPORT",
value: legacyIndexImport
.executionRootBasedBuildSettingPath
.pbxProjEscaped
),
.init(key: "ONLY_ACTIVE_ARCH", value: "YES"),
.init(
key: "PROJECT_DIR",
Expand Down
Loading