Skip to content

Instantly share code, notes, and snippets.

@gjazali
Last active May 10, 2025 14:47
Show Gist options
  • Save gjazali/19979a9f0af36ec9bb0652652d85f207 to your computer and use it in GitHub Desktop.
Save gjazali/19979a9f0af36ec9bb0652652d85f207 to your computer and use it in GitHub Desktop.
Get `sourcekit-lsp` to work with Xcode project structures

Get the sourcekit-lsp to work with Xcode project structures

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment