Fix: Windsurf Swift Code Completion and Diagnostics Not Working

If Windsurf gives you no Swift completion, missing diagnostics, or no go-to-definition, the cause is almost always SourceKit-LSP. Here's how to diagnose and fix Swift language intelligence step by step.

The symptom and the usual cause

You open a Swift file in Windsurf and get nothing useful: no autocomplete, no inline errors, no jump-to-definition.

In almost every case the root cause is the Swift language server, SourceKit-LSP, not running or not connected. Windsurf itself is fine; the Swift intelligence layer is missing.

SourceKit-LSP is Apple's official language server that ships with the Swift toolchain. If it cannot find the toolchain or cannot understand your project, you lose completion.

The good news is that this is a configuration problem with a reliable checklist, not a dead end.

Step 1: Confirm the Swift toolchain is installed

Open the integrated terminal and run `swift --version`. You should see a valid Swift version.

Then run `xcode-select -p` to confirm the active developer directory points at a real Xcode install. If it does not, run `sudo xcode-select -s /Applications/Xcode.app` to fix it.

If `swift` is missing entirely, install the Command Line Tools with `xcode-select --install` and, ideally, a full Xcode from the App Store.

Without a working toolchain, no language server can function. This is the foundation, so verify it first.

Step 2: Verify SourceKit-LSP exists

Run `xcrun --find sourcekit-lsp` in the terminal. This should print a path to the language server binary that ships with your toolchain.

If it prints a path, SourceKit-LSP is present and the problem is connection or configuration, not installation.

If it errors, your toolchain selection is wrong. Revisit Step 1 and make sure `xcode-select` points at a complete Xcode, not just partial command line tools.

Note that path so you can point the Swift extension at it explicitly if auto-detection fails.

Step 3: Install and check the Swift extension

Make sure the Swift language extension is installed in Windsurf from the marketplace. The official Swift extension is the most reliable.

After installing, fully reload the window. Language servers often only attach on a fresh window load, so a reload resolves a surprising number of cases.

Open the extension's settings and confirm it is using the right toolchain. If auto-detection fails, set the SourceKit-LSP path from Step 2 manually.

Check for multiple competing Swift extensions. Having two installed can cause conflicts, so keep just one.

Step 4: Open the project the way the server expects

SourceKit-LSP reasons about your code through the build system. For Swift packages, open the folder that contains `Package.swift` at the root.

If you opened a nested subfolder or a folder without a package or recognizable build setup, the server may not know how to index. Reopen at the correct root.

For `.xcodeproj`-based apps, expect weaker results, because Xcode-specific build settings are not fully visible to the language server. Swift sources still get coverage, but Xcode-only constructs may not.

When possible, evaluate completion on a Swift Package Manager project first to confirm the setup works at all.

Step 5: Generate fresh build artifacts

The language server works best when build products and an index exist. If completion is empty, build once from the terminal.

For a package, run `swift build`. For an app, run an `xcodebuild` build for your scheme. This produces the artifacts SourceKit-LSP needs to resolve symbols.

After a successful build, give the server a moment to index, then reopen a Swift file and test completion again.

If the project does not build at all, fix the build first. A language server cannot fully index code that does not compile.

Step 6: Read the language server logs

When the checklist does not solve it, look at the output. Open the Output panel and select the SourceKit-LSP or Swift channel.

The logs usually state plainly what went wrong: a missing toolchain, a crash, or an inability to find the build. Let the error guide your fix.

If you see repeated crashes, your toolchain and Xcode versions may be mismatched. Align them, since the language server expects the toolchain it shipped with.

Restart the language server (or reload the window) after any change and recheck the logs to confirm it now starts cleanly.

Step 7: When to fall back to Xcode

If a particular complex app target simply will not index well in Windsurf, that is a known limitation, not a failure on your part.

Xcode has the deepest understanding of intricate, multi-target app projects. For heavy navigation and indexing in those cases, lean on Xcode.

Keep a practical split: use Windsurf with SourceKit-LSP for everyday Swift authoring and package code, and Xcode for the most Xcode-specific work.

This hybrid approach gives you AI-assisted editing where it works well, without fighting the tool where Xcode is simply stronger.

Rule out the simple culprits first

Before assuming a deep configuration problem, eliminate the boring causes, because they account for a large share of cases. The most common is simply not having reloaded the window after installing or updating the Swift extension.

Another is a toolchain that changed underneath you. If you updated or switched Xcode versions, the path that `xcode-select` points at may no longer match the toolchain the extension cached, and a fresh `xcode-select -s` plus a reload often fixes it.

A project that has never been built is a third frequent cause. The language server has little to index until artifacts exist, so an empty result on a brand-new checkout is expected until you run a build.

Walking these three checks first, reload, toolchain path, and an initial build, resolves many reports without touching logs at all.

Keep completion healthy over time

Even once it works, language intelligence can degrade as a project grows or as you switch branches. A few habits keep it reliable.

Rebuild after large dependency changes, since a stale index can leave the server resolving symbols that no longer exist or missing ones that now do. A quick `swift build` refreshes its understanding.

If completion suddenly goes quiet mid-session, reload the window before assuming anything is broken. Long-running language servers occasionally drop their connection, and a reload reattaches cleanly.

When you upgrade Xcode, expect to do a one-time toolchain re-point and reload. Treating that as routine, rather than a surprise, keeps the editor's Swift support steady release after release.

It also helps to keep the Swift extension itself up to date, since fixes for language-server connection issues land there regularly. An outdated extension paired with a current toolchain is a common source of intermittent completion problems.

Finally, when you do open a genuinely large app target, give the first index pass time to finish before judging the result. Early emptiness during indexing is normal and is not the same as a broken setup.

Frequently Asked Questions

Why is Swift autocomplete not working in Windsurf?

Almost always because SourceKit-LSP, the Swift language server, isn't running or connected. Check that the Swift toolchain is installed, the Swift extension is active, and you've opened the project at the correct root.

How do I check if SourceKit-LSP is installed?

Run xcrun --find sourcekit-lsp in the terminal. If it prints a path, the language server exists and your issue is configuration. If it errors, fix your toolchain selection with xcode-select first.

Why does completion work for packages but not my app?

SourceKit-LSP reasons through the build system and has full visibility into Swift Package Manager projects. Xcode-specific build settings in .xcodeproj apps aren't fully visible, so coverage is weaker there.

What if indexing still won't work for a big app?

That's a known limitation. Xcode has the deepest understanding of complex multi-target projects. Use Windsurf for everyday Swift editing and fall back to Xcode for heavy navigation in intricate app targets.