SolaWing / xcode-build-server

a build server protocol implementation for integrate xcode with sourcekit-lsp
MIT License
428 stars 19 forks source link

[Fix] Cross References Not Working with LSP #55

Closed arshonsaadati closed 5 months ago

arshonsaadati commented 6 months ago

Firstly, thank you so much for building this tool. It is a great pleasure to be able to use my NeoVim environment to code swift!✨

I had a lot of trouble getting the BSP to work with sourcekit lsp, and couldn't find any resources online so documenting my issues and fix in case anyone stumbles on this.

I was unable to get cross-file references to work. The sourcekit lsp was unable to find project references in scope. The issue arised from xcode-build-server not being able to find the build_root after the config step, and a symptom of this is if your "build_root" property in your buildServer.json looks like "build_root": "/Users/arshonsaadati" rather than "build_root": "/Users/arshonsaadati/Library/Developer/Xcode/DerivedData/Simulator_Controller-adadrfjxhdizubdktugddworgvuj". If this is the case, the server.py of the BSP will hang waiting for stdin.

FIX: The source of the issue is xcode-select if running xcode-select in your command line gives the error xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance. It can be fixed by running sudo xcode-select -s /Applications/Xcode.app/Contents/Developer.

Assuming Xcode is installed in your applications folder, xcode-select, xcodebuild, and xcode-build-server config should function correctly. I've attached a buildServer.json that works for my project as an example, since as a noob I was confused what to put for the scheme argument. buildServer.json

Feel free to close this issue, as no action is required! Thank you!

SolaWing commented 6 months ago

Thank you for your response. here may need a doctor command to auto check environment and tip user how to fix it.

selfire1 commented 4 months ago

That comment really helped me, thank you @arshonsaadati !

If you do have space @SolaWing to add a doctor command that would be helpful in my experience 😌