![如何让 sourcekit-lsp 在 VS Code 中工作?(适用于 Swift)](https://linux22.com/image/1174757/%E5%A6%82%E4%BD%95%E8%AE%A9%20sourcekit-lsp%20%E5%9C%A8%20VS%20Code%20%E4%B8%AD%E5%B7%A5%E4%BD%9C%EF%BC%9F%EF%BC%88%E9%80%82%E7%94%A8%E4%BA%8E%20Swift%EF%BC%89.png)
我一直在尝试使用 VS Code 设置 Swift 开发,为此我一直遵循本教程: 使用 Visual Studio Code 进行快速开发 — 在 Linux 上!,但是经过一番尝试后,我遇到了一个问题,提示无法启动 SourceKit 语言服务器。它还说无法使用命令 sourcekit-lsp 启动服务器。
仍然没有解决,执行时出现以下情况swift build -Xcxx -I/home/nikko/swift/swift-5.2.4-RELEASE-ubuntu20.04/usr/lib/swift
/home/nikko/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCclibc/process.c:9:12: warning: implicit declaration of function 'posix_spawn_file_actions_addchdir_np' is invalid in C99 [-Wimplicit-function-declaration]
return posix_spawn_file_actions_addchdir_np(file_actions, path);
^
1 warning generated.
/home/nikko/Downloads/sourcekit-lsp/.build/checkouts/swift-driver/Sources/SwiftDriver/Utilities/Triple.swift:1637:3: error: unknown attribute '_spi'
@_spi(Testing) public var isMacCatalyst: Bool {
^
/home/nikko/Downloads/sourcekit-lsp/.build/checkouts/swift-driver/Sources/SwiftDriver/Utilities/Triple.swift:1637:3: error: unknown attribute '_spi'
@_spi(Testing) public var isMacCatalyst: Bool {
^
/home/nikko/Downloads/sourcekit-lsp/.build/checkouts/swift-driver/Sources/SwiftDriver/Utilities/Triple.swift:1637:3: error: unknown attribute '_spi'
@_spi(Testing) public var isMacCatalyst: Bool {
^
/home/nikko/Downloads/sourcekit-lsp/.build/checkouts/swift-driver/Sources/SwiftDriver/Utilities/Triple.swift:1637:3: error: unknown attribute '_spi'
@_spi(Testing) public var isMacCatalyst: Bool {
^
/home/nikko/Downloads/sourcekit-lsp/.build/checkouts/swift-driver/Sources/SwiftDriver/Utilities/Triple.swift:1637:3: error: unknown attribute '_spi'
@_spi(Testing) public var isMacCatalyst: Bool {
^
/home/nikko/Downloads/sourcekit-lsp/.build/checkouts/swift-driver/Sources/SwiftDriver/Utilities/Triple.swift:1637:3: error: unknown attribute '_spi'
@_spi(Testing) public var isMacCatalyst: Bool {
^
/home/nikko/Downloads/sourcekit-lsp/.build/checkouts/swift-driver/Sources/SwiftDriver/Utilities/Triple.swift:1637:3: error: unknown attribute '_spi'
@_spi(Testing) public var isMacCatalyst: Bool {
^
[44/52] Compiling SwiftDriver DriverExecutor.swift
(顺便说一下,它停在 44/52。每次都没有完成)
奇怪的是,我在谷歌上找不到关于这个“_spi”的任何有用信息(除了它可能意味着串行外设接口)。
答案1
找到并遵循本指南后: https://www.raywenderlich.com/8325890-a-complete-guide-to-swift-development-on-linux
我发现我必须
rm -rf .build/
在项目文件夹中写入,因为如果该文件夹已经存在,sourcekit-lsp 就会失败。
还不够,我遇到了未知属性“_spi”的问题