Skip to main content
On this page

Code completion

Completion, go to definition and live errors for Swift, SwiftUI and Objective-C, third-party libraries, and what to do when completion is off.

Open your iOS project and you get code completion, go to definition, hover docs, find references and live errors for Swift, SwiftUI, Objective-C, C and C++. Results follow your project's real settings, just as accurate as writing code in Xcode.

The first time you open a project

The first time you open a project, the extension adds a buildServer.json to the project root. Code completion needs it, and you can add it to .gitignore. If you've used a tool such as xcode-build-server and the file already exists, it's left alone; to switch to KXApp's completion, delete it and reload the window.

SPM dependencies, CocoaPods and the app's own modules need a build before they can be completed. If the project hasn't been built yet, the extension quietly builds the current scheme in the background (without signing), so completion usually appears within seconds. A build you start yourself takes over right away. To turn the background build off, disable kxapp.build.prepareForCodeCompletion.

Switching scheme and destination

Results follow the selected scheme, configuration and run device, and update when you switch. "No such module" errors from before the first build clear up by themselves once the build finishes.

When results look wrong

CommandWhen to use it
kxapp: Restart Code CompletionCompletion is stuck or diagnostics are clearly out of date
kxapp: Re-Index ProjectGo to Definition or Find References misses symbols that exist

VS Code treats .h files as C++ by default. Completion still works, but Objective-C highlighting is off. Add this to your settings:

"files.associations": { "*.h": "objective-c" }

Related settings

SettingDescription
kxapp.swiftSourcekitLspSupportedLanguagesLanguages handled by SourceKit-LSP. Remove C / C++ to let another extension such as clangd handle them
kxapp.swiftSourcekitLspBackgroundIndexingBackground indexing: auto / on / off
kxapp.swiftPathUse a different Swift toolchain; empty means the Xcode selected with xcode-select
kxapp.swiftSourcekitLspDisableTurn code completion off

All settings are in the settings reference.

Next steps