Can sourcekit-lsp provide a LSP service for cross-compiled code?

Dear Swift Community,

Xcode can cross-compile applications to WatchOS/tvOS/iOS/iPadOS, and provide code completion for frameworks/libraries only available on those platforms using sourcekit. Can sourcekit-lsp use Swift cross-compilation toolchains* to provide code completion for those toolchain's compilation target, e.g. x86_64-unknown-linux-gnu?

* SwiftCrossCompilers and SPMDestinations.


I'm not familiar with those particular projects. A few general comments:

  • In principle the sourcekit-lsp that is included in a given Swift toolchain should be able to support all of the same targets that the compiler and swiftpm can support. We use the same underlying technology.
  • That being said, this isn't specifically being tested so there may be gaps, particularly around configuration. For example, we expose a few swiftpm-style options like -Xswiftc in sourcekit-lsp, but we may be missing something that is important for cross-compilation use-cases.
  • We would generally be open to contributions to bring sourcekit-lsp in line with swiftpm if there are scenarios that work in swiftpm but not sourcekit-lsp.

Cross-compilation is achieved using:

$ swift build --destination /path/to/destination.json

The destination.json is available in the cross-compilation toolchain.

Can sourcekit-lsp support SwiftPM build flags like --destination or --static-swift-stdlib?

We do not currently support the --destination option in sourcekit-lsp. @Max_Desiatov looked at adding it a while ago, but I don't recall what specific issues he ran into.

I wouldn't expect --static-swift-stdlib to matter for sourcekit-lsp since we're not going to link the code.

Terms of Service

Privacy Policy

Cookie Policy