I want to run some tests in SourceKit-LSP while using a local build of SourceKit. I have already followed the Getting Started Guide and have a local build. However, I'm not sure what the proper way is to get SourceKit-LSP to use this local build of SourceKit.
I tried the SWIFTCI_USE_LOCAL_DEPS environment variable, but that's primarily intended for CI as far as I can see, it also didn't seem to work for me. The test ran normally, but it didn't seem to use my local SourceKit build.
I have also tried the SOURCEKIT_TOOLCHAIN_PATH environment variable, but couldn't get it to work. I set it to /Users/steffen/dev/swift-project/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64. This causes the test to fail with one of two errors:
Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0., NSJSONSerializationErrorIndex=0}
or
ResponseError(code: LanguageServerProtocol.ErrorCode(rawValue: -32001), message: "Build server failed to initialize", data: nil)
I also see this output from SourceKit in the terminal:
sourcekit: [1:connection-event-handler:11015: 0.0000] Connection interrupt
sourcekit: [1:updateSemanticEditorDelay:11015: 0.0003] disabling semantic editor for 10 seconds
sourcekit: [1:pingService:11015: 0.0003] pinging service
sourcekit: [1:sourcekitd_send_request:12035: 0.0026] request dropped while restoring service
sourcekit: [1:pingService:11015: 0.0246] pinging service
sourcekit: [1:connection-event-handler:4355: 0.0247] Connection interrupt
sourcekit: [1:updateSemanticEditorDelay:4355: 0.0247] disabling semantic editor for 10 seconds
sourcekit: [1:pingService:4355: 0.0247] pinging service
sourcekit: [1:pingService:14851: 0.0482] pinging service
sourcekit: [1:pingService:15367: 0.0482] pinging service
sourcekit: [1:connection-event-handler:4355: 0.0483] Connection interrupt
sourcekit: [1:updateSemanticEditorDelay:4355: 0.0483] disabling semantic editor for 10 seconds
sourcekit: [1:pingService:4355: 0.0483] pinging service