tl;dr My current work around is to stop the language server after adding an
import statement to a
systemLibrary. Then restart it.
So I kept playing with it last night. I finally got it working. Sort of. I think there is some bug but I'm not quite sure how to describe it or where it comes from yet. I'm still trying to come up with a minimal reproduction of it. I'm also not sure if it is just
systemLibrary targets or all.
I noticed that whenever adding a new file that contains an
import to a
systemLibrary I have to stop the language server and restart it. Then the diagnostics disappear.
Preliminary Reproduction Steps
I've gone ahead and pushed the scaffold of the library here. It is presumed that VSCode and sourcekit-lsp are already properly configured.
git clone https://github.com/RLovelett/swift-libgpiod.git
git checkout 460046249da35b34570a357bace1af44745f1d97
main.swift and you should see no diagnostic errors.
git checkout 24ed5f06876182e4bd17e162e3017fe4f99cc796
Note: Before doing this 2nd
git checkout do not close VSCode or sourcekit-lsp.
- I typically run the
git checkout on a terminal external to VSCode but I don't think this is necessary.
main.swift still open there should now be an error
use of unresolved identifier 'Chip' originating from
Chip.swift there is now an error
no such module 'Clibgpiod' originating from
- Also note that at this time and at every step previously
swift build and
swift run worked fine.
- Now close VSCode and re-launch. All the diagnostic errors are gone and the language server works as expected (until a new file
importing Clibgpiod is made).
This was all done on Ubuntu 19.10 with a daily build of the
master branch of the Swift toolchain from 17 March 2020.