The sourcekit-lsp
, in its current capabilities, is unable to understand the structures of Xcode projects. Meaning, when using it, you will encounter errors that marks some symbols as unidentified if they reside on a different .swift
file.
To remedy this, we can use the xcode-build-server
tool, which works by providing to sourcekit-lsp
information about the Xcode project we're working on.
Before installing it, make sure to run the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
This will prevent the xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
error from appearing.
With Homebrew, the installation is straightforward:
brew install xcode-build-server
To use it for a project, run:
xcode-build-server config -project *.xcodeproj
or
xcode-build-server config -workspace *.xcworkspace
based on whether or not you have a workspace configured for that project. Regardless of that, you should run the above command in the root directory of the Xcode project.
After this, xcode-build-server
should generate a buildServer.json
file in the root directory.