From 15bfe743478c26365008039059b9ad9a9c2b0062 Mon Sep 17 00:00:00 2001 From: Bruno Henrique da Rocha e Silva Date: Sun, 11 Jan 2026 15:41:14 +0100 Subject: [PATCH] Fix BSP not working with rules_apple 4.3.3 --- Example/.bazelrc | 1 + Example/MODULE.bazel | 4 ++-- .../BuildTargets/BazelTargetQuerierParser.swift | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Example/.bazelrc b/Example/.bazelrc index abda0ddb..0ca1c7f5 100644 --- a/Example/.bazelrc +++ b/Example/.bazelrc @@ -1,5 +1,6 @@ common --ios_simulator_device="iPhone 16 Pro" common --ios_simulator_version="18.6" +common --watchos_cpus=arm64 # rules_swift flags migration # --swiftcopt and --host_swiftcopt are deprecated diff --git a/Example/MODULE.bazel b/Example/MODULE.bazel index 02899d0e..0ad88325 100644 --- a/Example/MODULE.bazel +++ b/Example/MODULE.bazel @@ -6,13 +6,13 @@ local_path_override( bazel_dep( name = "rules_swift", - version = "3.3.0", + version = "3.4.0", repo_name = "build_bazel_rules_swift", ) bazel_dep( name = "rules_apple", - version = "4.3.2", + version = "4.3.3", repo_name = "build_bazel_rules_apple", ) diff --git a/Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BazelTargetQuerierParser.swift b/Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BazelTargetQuerierParser.swift index 93701eec..67fa542c 100644 --- a/Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BazelTargetQuerierParser.swift +++ b/Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BazelTargetQuerierParser.swift @@ -584,11 +584,17 @@ extension BazelTargetQuerierParserImpl { let cpuComponents = try configComponents.getIndexThrowing(0).split(separator: "_", maxSplits: 1) let platform = try cpuComponents.getIndexThrowing(0) let cpuArch = try cpuComponents.getIndexThrowing(1) + // To support compiling libraries directly, we need to additionally strip out // the transition and distinguisher parts of the configuration name, as those will not // be present when compiling directly. - let configWithoutTransitionOrDistinguisher = configComponents.dropLast(3) + + // Edge case: rules_apple 4.3.3 dropped configuration distinguishers + let stepsToDrop = try configComponents.getIndexThrowing(5).hasPrefix("applebin_") ? 3 : 2 + + let configWithoutTransitionOrDistinguisher = configComponents.dropLast(stepsToDrop) let effectiveConfigurationName = configWithoutTransitionOrDistinguisher.joined(separator: "-") + return BazelTargetConfigurationInfo( configurationName: fullConfig, effectiveConfigurationName: effectiveConfigurationName,