I am slowly writing a book on Exploring! Check it out, and be the first one to read it!

Exploring Cursor AI Editor for iOS Development
This book offers a practical guide to use the AI-powered code editor, Cursor, and incorporate it in your daily Swift and SwiftUI workflows.What you will learn:Hot Reloading for Faster Iteration: Set up hot reloading with Cursor and Inject to see code changes reflected instantly in the simulator, speeding up your development process.AI-Assisted Coding in Swift: Utilize Cursor’s AI capabilities for code generation, refactoring, and creating UI elements directly from simple prompts and Cursor rules.Understand Cursor’s Composer: Explore Composer’s advanced functionalities for managing multi-file edits, refining UI using screenshots, integrating external documentation and browsing the web.Debugging Strategies: Troubleshoot and resolve common issues that may arise when using Cursor and AI-generated code.This book is for:iOS developers looking for ways to improve their workflow with AI assistance and reduce friction.

After knowing about Cursor, I am exploring ways to avoid context switching between Xcode and Cursor. While compile-time errors is still something that I am figuring out, I setup Cursor to build and run iOS apps directly on the simulator, without needing to open Xcode.

Finding the Right Extension

I think I tried every Swift and iOS-related extension available in Cursor's marketplace. While they were helpful, none solved the build-and-run problem.

On X, the creator of Sweetpad, an extension for Cursor, mentioned about it in a comment. Initially, I had an issue with the extension, but after reporting it on GitHub, Yevhenii quickly resolved them.

No affliation, but it is something I recommend:

SweetPad (iOS/Swift development) - Visual Studio Marketplace
Extension for Visual Studio Code - Develop Swift/iOS projects in VS Code

Installing Sweetpad is straightforward, so I will spare the details on it. What I wanted was the keyboard shorcuts. I chose the target simulator (iPhone 15 Pro) and default Xcode scheme to build as Meshing.

Keyboard Shortcuts

For building and running, I used Control+Command+R (as Command+R had too many conflicts):

{
  "key": "ctrl+cmd+r",
  "command": "sweetpad.build.launch"
}

For building, I set it to Command+B, similar to Xcode:

{
  "key": "cmd+b",
  "command": "sweetpad.build.build"
}

These allow me to build and run the app, launching the given simulator directly from Cursor.

Hot Reload

To avoid relying on Xcode's previews, I use the Inject framework:

GitHub - krzysztofzablocki/Inject at rudrank.com
Hot Reloading for Swift applications! . Contribute to krzysztofzablocki/Inject development by creating an account on GitHub.

I have set up rules to inject the necessary code into my views automatically. You can read about it here:

Exploring Cursor: Rules for AI Using cursorrules
Boost SwiftUI development with Cursor and custom .cursorrules. Leverage Claude Sonnet 3.5 for up-to-date iOS 17 APIs, async/await implementation, and hot reloading with Inject. Learn how to set up .cursorrules for streamlined development and reduce coding friction.

Whenever I make changes, they instantly appear in the simulator without needing to rebuild the entire app.

Moving Forward

While it took a bit of effort to set up, the resulting workflow is worth it. I can now write code, build, run, and see changes all within Cursor while using Claude Sonnet 3.5. The main goal of reducing the friction of switching IDEs and between browser is working out well.

I have realised it is better to learn more about working with LLM powered IDEs to be more productive and adapt to the new world.

Happy cursoring!

Astro Affiliate.

Astro (Affiliate)

Find the right keywords for your app and climb the App Store rankings. Improve your app visibility and increase your revenue with Astro. The first App Store Optimization tool designed for indie developers!

Tagged in: