LSP for Swift + Objective C codebase

I’m working in a codebase with a mixture of Objective C, Objective C++, and Swift and I have installed some extensions like Swift and Clangd.

However, basic LSP functions like go-to-definition, find-references, completion don’t work well at all.

Anyone got the experience setting up LSP for OC and Swift? or should I just give up this idea and do code edits in XCode instead. Thanks in advance!

Hey, it’s worth separating two things here: what Cursor does, and what extensions do.

Cursor ships only with TextMate grammars for Swift and Objective-C, so syntax highlighting and brackets. All LSP features like go-to-definition, find-references, and completion come from Marketplace extensions, and for a mixed Swift and ObjC project you need to set them up correctly.

Swift extension sswg.swift-lang wraps SourceKit-LSP. You need a Swift toolchain installed, on macOS that means the full Xcode, not just Command Line Tools. Check:

  • xcrun --find sourcekit-lsp returns a path
  • The extension Output panel shows no errors when you open a .swift file

Clangd extension llvm-vs-code-extensions.vscode-clangd for Objective-C and C++ needs a compile_commands.json in the project root. Without it clangd can’t resolve includes and frameworks. You can generate it with GitHub - SolaWing/xcode-build-server: a build server protocol implementation for integrate xcode with sourcekit-lsp · GitHub or bear. I also recommend disabling the built-in C and C++ IntelliSense so it won’t conflict with clangd.

Main caveat: cross-language navigation Swift to Objective-C and back, via bridging headers, @objc APIs, and so on is poorly supported by both LSPs on their own. That’s a limitation of the language servers, not Cursor. In Xcode this is handled by a unified index, which SourceKit-LSP and clangd don’t have.

In practice, for a mixed codebase a good workflow is to edit and use AI features in Cursor, but build and do cross-language navigation in Xcode. Also worth checking Xcode | Cursor Docs, there’s a native plugin for integration.

Related forum threads for iOS and Swift: Any tips for Swift and Is it even possible to build an iOS app with Cursor?.

Thank you @deanrie for the reply! Really appreciate the effort. I will give it a try.