-
Notifications
You must be signed in to change notification settings - Fork 117
Bug: Stack trace paths with leading slash not clickable in Xcode #3290
Description
Bug: Stack trace paths with leading slash not clickable in Xcode
Target Repository: https://github.com/MobileNativeFoundation/rules_xcodeproj/issues
Description
Stack traces and diagnostic messages in Xcode display workspace-relative file paths with a leading slash (e.g., /Projects/Modules/Service/CoreDataService/Source/SetupProcedure.swift:61). However, clicking on these paths does nothing - Xcode cannot navigate to the files.
Root Cause: The generated ~/.lldbinit-rules_xcodeproj file contains source-map entries for paths starting with ./ but is missing a mapping for paths starting with / (leading slash without dot prefix). These paths appear in debug symbols as workspace-relative but are interpreted by Xcode as absolute filesystem paths from root.
Current lldbinit Configuration
The generated ~/.lldbinit-rules_xcodeproj contains:
platform settings -w "/var/tmp/_bazel_username/.../execroot/_main"
settings set target.source-map ./bazel-out/ "/var/tmp/.../bazel-out"
settings append target.source-map ./external/ "/var/tmp/.../external"
settings append target.source-map "./" "/Users/username/Developer/workspace"
The last line maps ./ but not / (leading slash without dot), which is needed for paths in stack traces.
Reproduction steps
- Build an iOS application using
rules_xcodeproj - Run the app in Xcode and observe a crash or view stack traces in the Thread navigator
- Note that file paths appear as
/Projects/Modules/YourModule/Source/File.swift:123 - Click on any file path in the stack trace
- Observe that Xcode does not navigate to the file (nothing happens)
Example Stack Trace
#5 0x00000001119afd53 in SetupProcedure.makePersistentContainer(storeType:) at /Projects/Modules/Service/CoreDataService/Source/SetupProcedure.swift:61
#6 0x00000001119aeb33 in SetupProcedure.execute() at /Projects/Modules/Service/CoreDataService/Source/SetupProcedure.swift:38
#7 0x0000000111985a13 in CoreDataService.init(synchronousTestMode:storeType:bundle:walSizeLimitOptimizationEnabled:completion:) at /Projects/Modules/Service/CoreDataService/Source/CoreDataService.swift:312
Clicking on these paths in Xcode does nothing - they should navigate to the corresponding source files.
Expected behavior
Clicking on file paths in stack traces (including those with leading /) should navigate to the correct source file in Xcode, similar to how paths starting with ./ currently work.
Workaround
Manually add the missing source-map entry to ~/.lldbinit-rules_xcodeproj:
echo 'settings append target.source-map "/" "/Users/username/Developer/workspace/"' >> ~/.lldbinit-rules_xcodeprojThen restart Xcode. This makes the navigation work, but the fix is lost whenever the Xcode project is regenerated with Bazel.
Proposed Fix
Modify xcodeproj/internal/bazel_integration_files/create_lldbinit.sh to add the missing source-map entry:
diff --git a/xcodeproj/internal/bazel_integration_files/create_lldbinit.sh b/xcodeproj/internal/bazel_integration_files/create_lldbinit.sh
index 3e05aea6..b20f947f 100755
--- a/xcodeproj/internal/bazel_integration_files/create_lldbinit.sh
+++ b/xcodeproj/internal/bazel_integration_files/create_lldbinit.sh
@@ -29,6 +29,10 @@ echo "settings append target.source-map ./external/ \"$BAZEL_EXTERNAL\""
# `external` when set from swiftsourcefile
echo "settings append target.source-map ./external/ \"$build_external\""
+# Workspace-relative paths with leading slash (e.g., /Projects/...)
+# These appear in debug symbols and need to be mapped to the workspace root
+echo "settings append target.source-map \"/\" \"$execution_root/\""
+
# Project files and locally resolved external repositories
#
# lldb seems to match breakpoints based on the second argument, using a simpleThis adds a source-map for paths starting with / (workspace-relative with leading slash) and maps them to $execution_root (the workspace directory).
rules_xcodeproj version
2.12.1 (commit 637a94211aa7528ef92335b51825bf596b93bcf5)
Xcode version
26.0 (17A324)
Bazel version
9.x (via bazelisk)
rules_apple version
4.2.0
rules_swift version
2.8.2
Additional information
Verified Solution
I've tested this fix by manually adding the source-map entry to ~/.lldbinit-rules_xcodeproj, restarting Xcode, and confirming that clicking on stack trace paths now correctly navigates to the source files.
Related Issues
This is related to #3134 which addresses other lldbinit configuration concerns, though that issue focuses on global vs project-specific configuration rather than incomplete source-map entries.
Impact
- Affected workflow: Daily debugging sessions
- Frequency: Every time a crash or stack trace appears in Xcode
- Workaround complexity: Easy but temporary (lost on project regeneration)
- User base: Anyone using rules_xcodeproj for iOS/macOS development with Xcode
I'm happy to submit a PR with this fix if that would be helpful!