mkbrwr
(Mykhailo Tymchyshyn)
August 8, 2024, 8:46am
1
I'm exploring swift-embedded-examples and would like to have LSP features in VS Code.
When I open Application.swift
file in stm32-uart-echo
example project Swift extension features like code completion and jump to definition do not work. As I understand this features depend on sourcekit-lsp
and I can see the errors in OUTPUT
view in VS Code for SourceKit Language Server
[Error - 11:15:04] Request textDocument/hover failed.
Message: sourcekitd request failed: error response (Request Failed): Loading the standard library failed
Code: -32001
As far I as understand Embedded Swift does not include standard library, so this error might be expected.
I have toolchain path configured.
Here's my settings.json
for VS Code
{
"swift.swiftEnvironmentVariables": {
"DEVELOPER_DIR": "/Applications/Xcode.app"
},
"swift.path": "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-08-05-a.xctoolchain/usr/bin",
"lldb.library": "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-08-05-a.xctoolchain/System/Library/PrivateFrameworks/LLDB.framework/Versions/A/LLDB",
"lldb.launch.expressions": "native"
}
Do I need to pass a configuration parameter to SourceKit-LSP for it to not try to load standard library ?
1 Like
I can reproduce this problem, and @ahoppen suggested we need a .sourcekit-lsp/config.json
file to pass the right flags (that we use when building) to the SourceKit compilations, too. Let me open a PR for it: stm32-uart-echo: Add a .sourcekit-lsp/config.json file to pass triple (and other flags) to SourceKit compilations by kubamracek · Pull Request #47 · apple/swift-embedded-examples · GitHub
Would you be able to try it and see if that helps?
mkbrwr
(Mykhailo Tymchyshyn)
August 9, 2024, 5:18pm
3
Yes, this solved the problem, thanks !
I did a clean checkout on pr branch and LSP features work.
By the way, the project builds successfully but I can see some errors highlighted in code like
Cannot use metatype of type 'RCC.AHB1ENR.ReadWrite' in embedded SwiftSourceKit
But I guess that's a different problem. Initial issue is resolved, thanks again !
2 Likes
kubamracek
(Kuba Mracek)
August 9, 2024, 10:54pm
4
Yes, that's a separate issue. I think I've seen it before, would you mind opening a Github issue for it?
mkbrwr
(Mykhailo Tymchyshyn)
August 10, 2024, 8:57am
5
2 Likes
kubamracek
(Kuba Mracek)
August 20, 2024, 12:00am
6
Tried the latest downloadable toolchain and verified this is fixed now.
iMostfa
(Mostfa Essam)
December 23, 2024, 11:14am
7
i don't know if it's common, but for me sourcekit-lsp was failing
after updating my mac.
sourcekit: -32001: sourcekitd request failed: error response (Request Failed): Loading the standard library failed
running the project/workspace from Xcode solved it. i wish if sourcekit-lsp returned a more detailed error.