Setup Swift LSP in nvim

up:: SwiftUI onboarding, nvim, iOS Development

This was a helpful start, but I needed some extra info: The complete guide to iOS & macOS development in Neovim

Set up basic swift lsp

-- import lspconfig plugin
local lspconfig = require("lspconfig")
 
-- setup swift lsp
lspconfig.sourcekit.setup({
  capabilities = {
    workspace = {
      didChangeWatchedFiles = {
        dynamicRegistration = true,
      },
    },
  },
})

Source: Swift.org - Configuring Neovim for Swift Development

Set up xcode-build-server

Follow steps here: SolaWing/xcode-build-server: a build server protocol implementation for integrate xcode with sourcekit-lsp. I’m not sure what it does, but it’s needed to give lsp information about your project, eg. Views that you created.

These are for some additional detail:

For example, if your app’s scheme name is called “Book to Instagram”. You can find the scheme in XCode.

  1. Go to the root of the project
    • This is where .git folder is located, as well as /Book To Instagram.xcodeproj/ and Book-To-Instagram-Info.plist
  2. Run this command:
xcode-build-server config -project *.xcodeproj -scheme "Book To Instagram"
  1. Check buildServer.json is created and "build_root" looks like this: "/Users/joschuag/Library/Developer/Xcode/DerivedData/Book_To_Instagram-drbnymmcoilbagbgisylitgtfiqw"