Closed xenodium closed 4 years ago
Thanks for the detailed report. I can't reproduce your problem, I get good code completion for module Foo
and no spurious diagnostic messages:
<<error type>>
for type Foo
is suspicious. That kind of problems are usually caused by a mismatch in toolchain versions between the SPM version included in the language server and what your SPM project specifies in its manifest. Are you using Xcode 12 Beta? Could you try one of the following things and restart Emacs to see if it solves the problem?
Specify Swift 5.2 for your package. You can do that by running this command from inside your project folder: swift package tools-version --set 5.2
. That'll modify your Package.swift
accordingly.
If you really want to use 5.3, install a recent 5.3 toolchain from https://swift.org/download/#snapshots and configure the LSP client to point to it:
(setq lsp-sourcekit-executable "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/sourcekit-lsp")
I'm suspicious that there may be a Swift version mismatch in the SourceKit-LSP version that shipped in the first beta of Xcode 12. I haven't seen clear reports about this issue yet, though.
Let me know if any of the workarounds fix your issue. If yes, then we may need to report the bug to Apple so that they fix it in a next Xcode 12 beta; if not, we'll enable further LSP and SourceKit logging to see what's going on.
Thank you for this wonderful response. I'm an SPM noob and learned a few things here. Specifying Swift 5.2 for my package did the job for me.
Are you using Xcode 12 Beta?
That's right. Via (setq lsp-sourcekit-executable "/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp")
.
Specify Swift 5.2 for your package. You can do that by running this command from inside your project folder: swift package tools-version --set 5.2. That'll modify your Package.swift accordingly.
Thank you 👍
If you really want to use 5.3, install a recent 5.3 toolchain from https://swift.org/download/#snapshots and configure the LSP client to point to it:
I can do with 5.2 for now, but can also try the snapshots.
I'm suspicious that there may be a Swift version mismatch in the SourceKit-LSP version that shipped in the first beta of Xcode 12. I haven't seen clear reports about this issue yet, though.
Let me know if any of the workarounds fix your issue. If yes, then we may need to report the bug to Apple so that they fix it in a next Xcode 12 beta;
Any more useful info I can give?
$ xcode-select -p
/Applications/Xcode-beta.app/Contents/Developer
$ swift package --version
Swift Package Manager - Swift 5.3.0
$ swift --version
Apple Swift version 5.3 (swiftlang-1200.0.16.9 clang-1200.0.22.5)
Target: x86_64-apple-darwin19.4.0
I have checked Xcode 12 Beta 2 (released today), and the problem persists. The most interesting log message I get from the server is this one:
[Trace - 11:29:57 PM] Received notification 'window/logMessage'. Params: { "message": "package at '/Users/dmartin/Desktop/FooBar' is using Swift tools version 5.3.0 but the installed version is 5.2.0", "type": 4 }
I'll prepare a bug report for Apple. For now, the only workarounds that work are:
[Trace - 11:29:57 PM] Received notification 'window/logMessage'.
Params: {
"message": "package at '/Users/dmartin/Desktop/FooBar' is using Swift tools version 5.3.0 but the installed version is 5.2.0",
"type": 4
}
Are you using adding "--log-level" to lsp-sourcekit-extra-args
to see these kinds of logs or a is there somewhere else I can look in the future to diagnose things?
I'll prepare a bug report for Apple. For now, the only workarounds that work are:
Thank you. You've been super helpful. We can prolly close this issue.
Are you using adding "--log-level" to lsp-sourcekit-extra-args to see these kinds of logs or a is there somewhere else I can look in the future to diagnose things?
You can check the Emacs <-> Server communication logs by enabling debugging in the client:
(setq lsp-print-io t)
.M-x lsp-workspace-show-log
.Specific for Swift, you can add --log-level
to the SourceKit-LSP invocation to get more detailed information. If you need even more logging, you can enable SourceKit logging:
(setenv "SOURCEKIT_LOGGING" "3")
M-x lsp-restart-workspace
.M-x lsp-workspace-show-log
.This is great. Helps me (and hopefully others) diagnose things in the future.
Really enjoying Swift/LSP on Emacs. Muchas gracias!
Apple confirmed this is a bug in Xcode 12 Beta (https://forums.swift.org/t/should-sourcekit-lsp-from-xcode-12-beta-work-with-swift-5-3/38362/3?u=daniel_martin), so I've created FB7961416 to track it. I'll post here when Apple informs me that the bug is fixed.
Good to see confirmation. Thanks for following up.
I have tested this again with Xcode 12 Beta 5 and things seem to be working fine.
Thank you. BTW, I built the latest sourcekit-lsp and it feels way snappier.
Completion of Apple frameworks work really well. Thank you! Completion of my own types within a basic SPM project don't seem to be working:
Also no completion in FooBar.swift:
Am I misconfiguring things?
Project builds otherwise:
My Package.swift
Project structure
Foo.swift content