Closed benjiwolff closed 6 months ago
Tracked in Apple’s issue tracker as rdar://121696265
Do you still see the issue after building the package? sourcekit-lsp requires a build to find the modules to import.
Yes, the problem persists after deleting the .build
folder and building both the debug and release configurations.
Hmm, that’s very odd. Maybe we aren’t finding the build folder. Could you check if the problem persists when you:
swift build
and wait for it to finishimport SplitView
I followed the steps. I simply added an "x" on a new lined and saved the file before restarting Neovim (restarts lsp too). The issue persists.
Ah, I think I know what might be going on: Do you use sourcekit-lsp from the same toolchain snapshot that contains your swift build
or are they from different toolchain version, eg. because you built sourcekit-lsp from source on main
? SwiftPM moved the folder that contains the .swiftmodules
, changing the compiler arguments that are required to build the file. Since SourceKit-LSP contains its own copy of SwiftPM, the compiler arguments it gets might not be correct to correctly pick up the Swift modules. https://github.com/apple/sourcekit-lsp/pull/1046/files#diff-d58fae5b483fc1623905094d04af6418aa40c2a77652889be608feb158d15a7dR142-R147
Generally speaking, sourcekit-lsp should be used from the same toolchain that the Swift compiler is from. While mixing and matching sourcekit-lsp with different compiler versions often works, there’s no guarantee that it does.
Spot on! I did use the release version of swift (5.9) to build. Now that I build the module with the dev version that my sourcekit-lsp uses, I no longer get the missing module errors :)
Steps to reproduce:
Add a package to
Package.swift
e.g.:Import the module in a .swift file e.g. in
Sources/LspTest/LspTest.swift
:sourcekit-lsp
returns "No such module" e.g. in Neovim:Hint
This seems to be a new bug in the development version of
sourcekit-lsp
. Using the release version, I do not encounter this problem.