Setting Up the iOS Development Environment in Cursor
A Cursor Guide for iOS Engineers (Part 1)
About Cursor
For those new to it, let me give you a quick rundown: Cursor is a code editor forked from VSCode. It adds a ton of AI-assisted code editing features. If you've used Copilot in VSCode, you probably have an idea of what it feels like. Just imagine it being 10 times better than Copilot, packed with various AI features designed to boost your productivity. If you're already a VSCode user, it supports migration to Cursor, allowing you to keep using your existing VSCode extensions just as they are. By installing the CLI tools, you can launch it using commands like cursor or code.
Features
Tab, Chat, Composer (normal/agent)
Tab
An incredibly useful feature when using Cursor is Tab. It predicts the next code you need to change, highlights it, and moves you to that spot when you press Tab. Press Tab again, and it applies the code Cursor suggests. You can apply multi-line edits, linting, and formatting with a single tap. The Cursor team apparently built a new custom model specifically for this Tab feature. On January 13th, they rolled out an update for a new Tab model called Fusion. They say the goal of the Tab model is to eliminate latency in code editing, and this new Fusion model has made massive strides toward that. Word is, the Tab model is generating more code than any other existing LLM out there.
Chat
Think of the Chat feature as ChatGPT integrated directly into your code editor. But it comes with several handy built-in capabilities. You can choose from various models. It suggests code but doesn't apply it automatically, giving the engineer more room to intervene. You can access it using the shortcut Command + L. You can use Chat to understand code, ask questions about errors, or get suggestions for fixes. You can also use @Codebase to make it reference your entire codebase.
Composer
This is the main feature of Cursor. It allows Cursor to write and execute code directly. There are two modes: normal and agent. Normal mode is the early version of Composer before terminal integration. I highly recommend using agent mode. Agent mode writes code, fixes errors, and even runs it directly by integrating with the terminal. It's a feature that engineers using Cursor rely on daily, and it keeps getting better. You can access it via the shortcut Command + I.
Shall we set up the iOS development environment in Cursor then?
Required Tools
[Optional] swift-format
[Optional] xcbeautify
Xcode Build Server
This enables features like jump to definition and auto completion right inside Cursor.
# https://github.com/SolaWing/xcode-build-server
brew install xcode-build-serverSweetpad
Sweetpad is an extension that lets you build iOS apps right inside Cursor. It supports auto completion, Build/Run, formatting, device management, and even debugging. Sweetpad wraps xcodebuild commands so you can use them with shortcuts. For example, it lets you use Command + R—probably the most used shortcut in Xcode—exactly the same way in Cursor. You can map all the various commands you used in Xcode to behave just like they did.
First, you need to set up your project using the Xcode Build Server we installed earlier. If your project is large, this might take a bit of time.
Once the command finishes executing, a buildServer.json file will be generated in your project's root directory. The xcode build server references this file to enable sourcekit-lsp features like syntax highlighting and jump to definition. Debugging is also supported.
swift-format
# https://github.com/swiftlang/swift-format
brew install swift-formatTry adding the settings below to your .vscode/settings.json. It will trigger file formatting every time you save.
{
"[swift]": {
"editor.defaultFormatter": "sweetpad.sweetpad",
"editor.formatOnSave": true,
},
}My Impressions So Far
I've been using Cursor for iOS development over the past few weeks. I'm still a bit clumsy with it, to be honest. Of course, I'm using it alongside Xcode—about a 50:50 split. Cursor's Tab feature almost magically snaps exactly to where I need to write my next line of code. It swiftly executes multi-line changes with a single tab too. Using Cursor has easily doubled my productivity. I use Xcode's Copilot Extension as well, but it's just not as amazing as Cursor.
It's tough to ditch Xcode entirely, but once you get used to Cursor, you'll have gained a remarkably powerful AI tool for iOS development.
The founders of Cursor recently appeared on the Lex Fridman podcast. I highly recommend giving it a watch when you have some free time.