atyshka
(Alex Tyshka)
1
I have just installed the latest 5.01 toolchain release on Ubuntu 18.04 and I'm trying to setup a development environment in Visual Studio Code. I successfully built sourcekit-lsp and the visual studio code extension. I then created a Hello World package using swift package init to create a blank library and made no changes to it. However, when I open a file in VSCode, all imported modules are in red squiggles saying "no such module". This includes PackageDescription in my package.swift. However, the package builds just fine. Here is the output log:
2019-06-13 21:28:02.607 sourcekit-lsp[68996:c8c92700] manifest parse error(s):
<unknown>:0: error: unknown argument: '-package-description-version'
manifest parse error(s):
<unknown>:0: error: unknown argument: '-package-description-version'
2019-06-13 21:28:02.619 sourcekit-lsp[68996:c8c92700] failed to create SwiftPMWorkspace: the package does not contain a buildable target
failed to create SwiftPMWorkspace: the package does not contain a buildable target
2019-06-13 21:28:02.628 sourcekit-lsp[68996:c8c92700] could not open compilation database for /home/alex/swift-projects/HelloWorld/Package.swift
could not open compilation database for /home/alex/swift-projects/HelloWorld/Package.swift
2019-06-13 21:28:02.678 sourcekit-lsp[68996:c8c92700] could not open compilation database for /home/alex/swift-projects/HelloWorld/Package.swift
could not open compilation database for /home/alex/swift-projects/HelloWorld/Package.swift
Why does it complain that there's no buildable target even though the package builds just fine? And what about the other errors in the log? Please let me know if anyone has advice or is able to reproduce this issue!
Aciid
(Ankit Aggarwal)
2
It looks like your Swift toolchain and the copy of sourcekit-lsp are out of sync. But I don't really see a Swift 5 branch for sourcekit-lsp /cc @blangmuir
atyshka
(Alex Tyshka)
3
Alright, you are correct, it seems there is no version of sourcekit-lsp tagged for 5.0. I'm surprised that it would build just fine though.
This is because SPM engine uses -package-description-version that was introduced for > 5.0 swift compiler. This feature is used in runtime, hence the SPM and sourcekit-lsp build just fine.
When newer Swift 5.1 toolchain will be available to download, you can use that and it will work.
blangmuir
(Ben Langmuir)
5
Just to expand a bit on what @krzyzanowskim and @Aciid said: it builds correctly because building uses swiftpm+swiftc from 5.0. SourceKit-LSP links to libSwiftPM 5.1+, so it's mixing swiftpm 5.1 with swiftc 5.0. That used to "just work", but broke when swiftpm started passing the -package-description-version option that only exists in swiftc 5.1+.