Skip to main content
On this page

Code completion and indexing

Completion, go to definition and error checking for Swift, Objective-C and C/C++, ready as soon as you open the project. When you need to build once first, and what to do when completion misbehaves.

Supported files

FilesProvided by
.swiftBuilt into the extension. Starts the first time you open a Swift file.
.m .mm .h .c .cppThe clangd extension, installed alongside KXBuild

Don't run KXBuild's Swift support and the official Swift extension (swiftlang.swift-vscode) at the same time. If the official extension is installed, KXBuild steps aside and tells you once.

When you need to build first

Modules produced by other targets in the project, such as other frameworks or Swift packages, don't exist until they're built. Until then, imports of them show as not found. Build once and they resolve.

When code completion misbehaves

  1. Run KXBuild: Restart Code Completion. Use this too if you just installed the toolchain and the language server hasn't started.
  2. Run KXBuild: Re-Index Project after changing many files or switching branches.
  3. If a new file isn't recognized, make sure it's added to the project, then right-click the .xcodeproj in the Explorer and choose "Generate compile_commands.json".
  4. Check Output > SourceKit Language Server, or Output > clangd for Objective-C.

Next steps