The other day, I tried to open SwiftCrossUI in VS Code on a Linux box to test out some GTK-specific functionality. In short order I get errors from the Swift extension and notice that even the most basic LSP functionality isn’t working, and I’m seeing errors in the terminal output about missing GTK headers. After investigating this with @stackotter for a bit, we realized that I was getting these errors from the Gtk3Backend, and I only had GTK 4 installed (SwiftCrossUI has backends for both GTK 3 and GTK 4). Even if I installed GTK 3 I’d get similar errors from the WinUIBackend.
@stackotter also told me that that’s just what happens if you swift build without specifying a target, but I can’t even avoid that because I’m not running the command — the extension is.
What’s the best way to get the LSP working for the SwiftCrossUI and GtkBackend targets, while ignoring Gtk3Backend, WinUIBackend, etc?
Correct, the problem is that there are some targets that require system-level dependencies I don't have installed, and can't install. Normally this isn't an issue because I can just not import those targets, but if I open the package itself in VS Code then it tries to build all of them, and there is no system on which this will work (unless you somehow get AppKit, WinUI, and UIKit on the same machine).
I'm now getting different errors in the plugin's terminal output, such as
Creating working copy for https://github.com/stackotter/swift-libwebp
error: 'swift-libwebp': Couldn’t update repository submodules:
Submodule path 'libwebp': checked out '1344795cd5659d7526feee789be0991ba1e229fe'
Submodule 'libwebp' (https://github.com/the-swift-collective/LibWebPC) registered for path 'libwebp'
Cloning into '/home/bbrk24/workspace/swift-cross-ui/.build/checkouts/swift-libwebp/libwebp'...
BUG: builtin/submodule--helper.c:254: cannot have prefix 'libwebp/' and superprefix 'libwebp/'
Aborted (core dumped)
fatal: Failed to recurse into submodule path 'libwebp'
and
Creating working copy for https://github.com/the-swift-collective/libpng
error: 'libpng': Couldn’t update repository submodules:
Submodule 'libpng' (https://github.com/the-swift-collective/LibPNGC.git) registered for path 'libpng'
Cloning into '/home/bbrk24/workspace/swift-cross-ui/.build/checkouts/libpng/libpng'...
fatal: could not open '/home/bbrk24/workspace/swift-cross-ui/.build/checkouts/libpng/.git/modules/libpng/objects/pack/tmp_pack_a4CwbU' for reading: No such file or directory
fatal: fetch-pack: invalid index-pack output
fatal: clone of 'https://github.com/the-swift-collective/LibPNGC.git' into submodule path '/home/bbrk24/workspace/swift-cross-ui/.build/checkouts/libpng/libpng' failed
Failed to clone 'libpng'. Retry scheduled
Cloning into '/home/bbrk24/workspace/swift-cross-ui/.build/checkouts/libpng/libpng'...
fatal: could not open '/home/bbrk24/workspace/swift-cross-ui/.build/checkouts/libpng/.git/modules/libpng/objects/pack/tmp_pack_gxN3O8' for reading: No such file or directory
fatal: fetch-pack: invalid index-pack output
fatal: clone of 'https://github.com/the-swift-collective/LibPNGC.git' into submodule path '/home/bbrk24/workspace/swift-cross-ui/.build/checkouts/libpng/libpng' failed
Failed to clone 'libpng' a second time, aborting
So unfortunately I can't say what step was causing the error I was seeing previously. However, swift build without any flags does still give the same error.