Basic Workflow
The simplest way to use Cursor with Swift is to treat it as your primary code editor while still relying on Xcode for building and running your apps. You’ll get great features like:- Smart code completion
- AI-powered coding assistance (try CMD+K on any line)
- Quick access to documentation with @Docs
- Syntax highlighting
- Basic code navigation
Hot Reloading
When using Xcode workspaces or projects (instead of opening a folder directly in Xcode), Xcode can often ignore changes to your files that were made in Cursor, or outside of Xcode in general. While you can open the folder in Xcode to resolve this, you may need to use a project for your Swift development workflow. A great solution to this is to use Inject, a hot reloading library for Swift that allows your app to “hot reload” and update as soon as changes are made in real time. This does not suffer from the side effects of the Xcode workspace/project issue, and allows you to make changes in Cursor and have them reflected in your app immediately.Advanced Swift Development
This section of the guide was heavily inspired by Thomas
Ricouard and his
article
about using Cursor for iOS development. Please check his article for more
details and drop him a follow for more Swift content.
xcodebuild
CLI (and much more), and allows you to scan your targets, select the destination, build, and run your app just like Xcode. On top of that, it’ll set up your project for Xcode Build Server so you get all the features mentioned above.
Sweetpad Usage
Once Sweetpad is installed, and you have a Swift project open in Cursor, you should first run theSweetpad: Generate Build Server Config
command. This will generate a buildServer.json
file in the root of your project that allows the Xcode Build Server to work with your project.
Then, from either the Command Palette or the Sweetpad sidebar, you can select the target you want to build and run.
You need to build your project once to enable auto-completion, jump to definition,
and other language features.