ITADN

Swift language service fails to initialize from compile_commands.json with `/usr/bin/swiftc` paths

#2649Closedz2oh 创建于 2026-05-14
Z
z2ohcommented
### Swift version swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1) Target: arm64-apple-macosx26.0 ### Platform macOS 26.4.1 ### Editor VS Code, Swift extension 2.16.4 ### Description Sometime in the last ~month or two, sourcekit-lsp stopped working against our somewhat unique CMake build. After some debugging, I found it is a very similar issue to https://github.com/swiftlang/sourcekit-lsp/issues/2128, but with `/usr/bin/swiftc` being set as the `CMAKE_Swift_COMPILER`. I couldn't find a source of this somewhat recent regression for us. As far as I can tell, CMake should have always been resolving to `/usr/bin/swiftc`, so I don't have much insight as to what changed. I'm able to work around this fairly easily with something like: ``` if(APPLE AND NOT DEFINED CMAKE_Swift_COMPILER) execute_process(COMMAND xcrun -f swiftc OUTPUT_VARIABLE _resolved_swiftc OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND xcrun --sdk macosx --show-sdk-path OUTPUT_VARIABLE _resolved_sdkroot OUTPUT_STRIP_TRAILING_WHITESPACE) if(_resolved_swiftc AND _resolved_sdkroot) set(CMAKE_Swift_COMPILER "${_resolved_swiftc}") set(ENV{SDKROOT} "${_resolved_sdkroot}") endif() endif() ``` but I think it probably makes sense to do something like https://github.com/swiftlang/sourcekit-lsp/pull/2143 for `/usr/bin/swiftc`. ### Steps to Reproduce _No response_ ### Logging _No response_
关闭于 2026-05-15 1 条评论