Open schwjustin opened 2 months ago
what's your logs? did xcode-build-server startup? You can get details logs by export environment SOURCEKIT_LOGGING=3. In addition, if you have the smallest reproducible demo, I can also help confirm whether there is really an exception.
How do I view the logs @SolaWing?
SOURCEKIT_LOGGING=3 is use for LSP, not xcode-build-server commandline. you may set it by open vscode from shell by:
SOURCEKIT_LOGGING=3 code <directory>
SourceKit Language Server is the output window, but seems output is different, here is a sample output from mine:
if you set correctly, you will see Xcode Build Server Startup
, and server:use flags from
[2024-09-06 11:00:57.261] SourceKitServer: Request<initialize>(
id: 0,
clientID: ObjectIdentifier(0x0000000138006f10),
params: ...
: Optional(...)
)
[2024-09-06 11:00:57.418] SourceKitServer: Response<initialize(0)>(
success(LanguageServerProtocol.InitializeResult(capabilities: ...))
)
INFO:server:Xcode Build Server Startup
DEBUG:server:Req --> {"method":"build\/initialize","id":1,"params":{"rootUri":"file:\/\/\/Users\/wang\/Desktop\/personal\/OpenSource\/LinkMapAnalyzer\/","version":"1.0","capabilities":{"languageIds":["c","cpp","objective-c","objective-cpp","swift"]},"displayName":"SourceKit-LSP","bspVersion":"2.0"},"jsonrpc":"2.0"}
INFO:server:use flags from /Users/wang/Library/Caches/xcode-build-server/-Users-wang-Desktop-personal-OpenSource-LinkMapAnalyzer/compile_file-LinkMapAnalyzer-9f97ee80e24b515adc6fa42d72ce32b0
DEBUG:server:Res <-- {"jsonrpc": "2.0", "id": 1, "result": {"displayName": "xcode build server", "version": "0.1", "bspVersion": "2.0", "rootUri": "file:///Users/wang/Desktop/personal/OpenSource/LinkMapAnalyzer/", "capabilities": {"languageIds": ["c", "cpp", "objective-c", "objective-cpp", "swift"]}, "data": {"indexDatabasePath": "/Users/wang/Library/Caches/xcode-build-server/-Users-wang-Desktop-personal-OpenSource-LinkMapAnalyzer/indexDatabasePath-943bca20aaeb8b42a6c2611225bd1cfd", "indexStorePath": "/Users/wang/Library/Developer/Xcode/DerivedData/LinkMapAnalyzer-athuzhygqqkfgydhrkmmrruvfkvf/Index.noindex/DataStore"}}}
[2024-09-06 11:00:57.422] initialized build server xcode build server
DEBUG:server:Req --> {"params":{},"jsonrpc":"2.0","method":"build\/initialized"}
[2024-09-06 11:00:57.423] opened IndexStoreDB at /Users/wang/Library/Caches/xcode-build-server/-Users-wang-Desktop-personal-OpenSource-LinkMapAnalyzer/indexDatabasePath-943bca20aaeb8b42a6c2611225bd1cfd with store path /Users/wang/Library/Developer/Xcode/DerivedData/LinkMapAnalyzer-athuzhygqqkfgydhrkmmrruvfkvf/Index.noindex/DataStore
[2024-09-06 11:00:57.424] SourceKitServer: Notification<initialized>(
clientID: ObjectIdentifier(0x0000000138006f10),
params: InitializedNotification()
)
[2024-09-06 11:00:57.424] SourceKitServer: Notification<textDocument/didOpen>(
clientID: ObjectIdentifier(0x0000000138006f10),
params: DidOpenTextDocumentNotification(...)
)
sourcekit: [2:sourcekitd_initialize:3587: 0.0000] initializing
[2024-09-06 11:00:57.429] Using toolchain XcodeDefault (com.apple.dt.toolchain.XcodeDefault) for DocumentURI(storage: file:///Users/wang/Desktop/personal/OpenSource/LinkMapAnalyzer/LinkMapAnalyzer/ContentView.swift)
DEBUG:server:Req --> {"jsonrpc":"2.0","params":{"action":"register","uri":"file:\/\/\/Users\/wang\/Desktop\/personal\/OpenSource\/LinkMapAnalyzer\/LinkMapAnalyzer\/ContentView.swift"},"method":"textDocument\/registerForChanges","id":2}
DEBUG:server:Res <-- {"jsonrpc": "2.0", "id": 2, "result": null}
[2024-09-06 11:00:57.430] SourceKitServer: Request<textDocument/codeAction>(
id: 1,
clientID: ObjectIdentifier(0x0000000138006f10),
params: CodeActionRequest(...)
)
[2024-09-06 11:00:57.430] registerForChangeNotifications(/Users/wang/Desktop/personal/OpenSource/LinkMapAnalyzer/LinkMapAnalyzer/ContentView.swift)
[2024-09-06 11:00:57.431] SourceKitServer: Request<textDocument/documentColor>(
id: 2,
clientID: ObjectIdentifier(0x0000000138006f10),
params: DocumentColorRequest(...)
)
[2024-09-06 11:00:57.431] mainFilesContainingFile(/Users/wang/Desktop/personal/OpenSource/LinkMapAnalyzer/LinkMapAnalyzer/ContentView.swift) -> [LanguageServerProtocol.DocumentURI(storage: file:///Users/wang/Desktop/personal/OpenSource/LinkMapAnalyzer/LinkMapAnalyzer/ContentView.swift)]
[2024-09-06 11:00:57.432] SourceKitServer: Request<textDocument/diagnostic>(
id: 3,
clientID: ObjectIdentifier(0x0000000138006f10),
params: DocumentDiagnosticsRequest(...)
)
DEBUG:server:Res <-- {"jsonrpc": "2.0", "method": "build/sourceKitOptionsChanged", "params": {"uri": "file:///Users/wang/Desktop/personal/OpenSource/LinkMapAnalyzer/LinkMapAnalyzer/ContentView.swift", "updatedOptions": {"options": [...], "workingDirectory": "/Users/wang/Desktop/personal/OpenSource/LinkMapAnalyzer"}}}
sourcekit: [2:sourcekitd_send_request_sync-before:5383: 0.0088] {
key.request: source.request.editor.open,
key.name: "/Users/wang/Desktop/personal/OpenSource/LinkMapAnalyzer/LinkMapAnalyzer/ContentView.swift",
key.compilerargs: [
...
],
key.sourcetext: "..."
}
[2024-09-06 11:00:57.434] BuildServerHandler: Notification<build/sourceKitOptionsChanged>(
clientID: ObjectIdentifier(0x00000001384084d0),
params: FileOptionsChangedNotification(...)
)
@SolaWing so after I run SOURCEKIT_LOGGING=3 code
Is this the source of the problem?:
Am I supposed to have the SourceKit-LSP vs code extension?
output window of SourceKit Language Server,coming from Swift extension. you don’t need unofficial sourcekit extensions
@SolaWing what does your Swift output look like, not SourceKit Language Server? Just want to compare
Also what do I do if I don't see Swift or SourceKit Language Server in output tab?
10:52:30: SourceKit-LSP setup
10:52:30: Failed to find /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lldb-vscode
10:52:30: focus: undefined
nothing special..
I also notice swift not in output defaults, seems not startup. I manually run any swift command, and swift plugin runs, output is showing
I have the same problem! But in my case i'm using nvim.
From nvim everything seems to work (code completion, treessitter and lsp) but I can't go to references or definitions for the files inside my project and some modules seems unavailable (XCTests per example). Even with those problems, build seems to work fine.
I checked :LspLogs
and found:
[START][2024-09-24 20:42:44] LSP logging initiated
[ERROR][2024-09-24 20:42:44] .../vim/lsp/rpc.lua:770 "rpc" "/usr/bin/sourcekit-lsp" "stderr" "INFO:server:Xcode Build Server Startup\n"
[ERROR][2024-09-24 20:42:44] .../vim/lsp/rpc.lua:770 "rpc" "/usr/bin/sourcekit-lsp" "stderr" "INFO:server:use flags from /Users/ianmcukier/Library/Caches/xcode-build-server/-Users-ianmcukier-Develop-project_name/compile_file-Runner-b9e2be0482b1095404a27606b518e960\n"
My project is a flutter project package with cocoapods. It has the following structure:
project_name/
ios/ -> Contains all the .swift files (Classes/, Tests/ and project_name.podspec)
example/ -> Example project. I believe it imports the previous ios/ with cocoapods
ios/ -> Contains the .xcworkspace and .xcodeproject
and my lsp root directory is set as project_name/
Here is my buildServer.json located in project_name/
{
"name": "xcode build server",
"version": "0.2",
"bspVersion": "2.0",
"languages": [
"c",
"cpp",
"objective-c",
"objective-cpp",
"swift"
],
"argv": [
"/opt/homebrew/bin/xcode-build-server"
],
"workspace": "/Users/ianmcukier/Develop/project_name/example/ios/Runner.xcworkspace",
"build_root": "/Users/ianmcukier/Library/Developer/Xcode/DerivedData/Runner-azebgyrqyexluialaafuzdzvpwgt",
"scheme": "Runner",
"kind": "xcode"
}
On Xcode everything works fine. It has the following structure inside the .xcworkspace in the example/
folder
Am I missing any configurations? Does this structure not work with xcode-build-server?
I can provide more information if necessary. Would love to be able to work on swift with nvim instead of xcode.
@ianmcukier your config seems fine. you can export environment SOURCEKIT_LOGGING=3
to get more detail logs.
In addition, what is your xcode version and sourcekit-lsp version? and does it works previously or in other project?
@SolaWing I managed to make it work! I had a couple of Index.noindex
files that I think came from when i tried to configure xcode-build-server by hand. When deleted everything started working as expected.
The only thing that does not work is renaming variables with vim.lsp.buf.rename
, which gives me the error [LSP] Rename, no matching language servers with rename capability.
. Does sourcekit-lsp not have this functionality? Similarly with comments when I type gcc it doesn't comment and gives the following error option 'commentstring' is empty
but I fixed it with the plugin Comment.nvim.
Either way, thanks for the attention and great plugin! Finally I can stop using xcode :)
@ianmcukier I wonder why you has couple of Index.noindex? There shouldn't be a folder with the same name here.
rename supported in newest sourcekit-lsp, you may need to update it.
How to update sourcekit? I'm using MacOs with XCode 15.4 and swift 5.10. I don't think I can update XCode to 16 since it may break my project.
@ianmcukier ok I think you may wait until you can fixes the compatibility issues.
Hi, I have xcode-build-server working for autocomplete in my SwiftUI project but I have the following problems:
I tried installing the SourceKit-LSP extension, however, it made each error appear twice on hover
This project builds and runs just fine in Xcode. I also cleaned the build folder, rebuilt in Xcode, and restarted VS Code