OTFotf
All posts
Cursor

How I Built an Apple Watch Workout App Using Cursor and Xcode

12 min
How I Built an Apple Watch Workout App Using Cursor and Xcode

From zero Swift experience to a published Apple Watch app — how Cursor and AI-assisted development made native app creation accessible.

The Challenge: Native Without Experience

I wanted to build a simple workout tracker for Apple Watch — something that logs exercises, tracks heart rate, and shows weekly progress. The problem: I'm a web developer. I'd never written a line of Swift, never opened Xcode for a real project, and had zero experience with Apple's HealthKit framework.

Traditionally, this would mean weeks of learning Swift, SwiftUI, and Apple's platform APIs before writing a single useful line of code. With Cursor, I shipped a working app in 3 days.

The approach: use Cursor as my AI pair programmer, Xcode as the build/deploy tool, and my web development intuition as a guide. SwiftUI is surprisingly similar to React in its declarative approach — a fact that AI tools leverage well when you mention your background.

Setting Up the Workflow

The workflow for AI-assisted native development has a specific cadence.

1

Create the Xcode project

Start in Xcode — create a new watchOS app project with Swift and SwiftUI. This generates the project structure, build settings, and provisioning configuration that Cursor can't handle.

2

Open the project in Cursor

Open the Xcode project folder in Cursor. You'll edit Swift files in Cursor (for AI assistance) and use Xcode for building, previewing, and deploying. The two tools work in parallel on the same files.

3

Create a .cursorrules for Swift

Write a rules file that includes: 'This is a SwiftUI Apple Watch app. I'm a web developer learning Swift. Use SwiftUI best practices, explain Apple-specific patterns, and keep views simple.' This context dramatically improves output quality.

4

Build in Xcode, edit in Cursor

The loop: describe a feature in Cursor → generate Swift code → switch to Xcode to build and preview → fix any Xcode errors back in Cursor. This dual-tool workflow is essential for native development.

Building the UI with SwiftUI

SwiftUI was the biggest positive surprise. As a React developer, the declarative component model felt immediately familiar. Cursor generated excellent SwiftUI code from descriptions like:

'Create a workout list view showing today's exercises. Each row has the exercise name, sets x reps, and a green checkmark if completed. Use the watch's accent color for highlights.'

The AI produced clean SwiftUI with proper List, HStack, VStack compositions, SF Symbols icons, and watch-appropriate sizing. I needed to adjust some padding values (watch screens are tiny!) but the structure was consistently correct.

Key insights for watch UI:
- Keep everything minimal — watch screens show maybe 3-4 items at once
- Use system fonts and SF Symbols exclusively
- Digital Crown scrolling needs to be considered in layout decisions
- Complications (watch face widgets) are a separate, constrained design challenge

HealthKit Integration

HealthKit was where AI-assisted development truly shined. Apple's HealthKit API is powerful but complex — authorization flows, data types, query predicates, and background delivery are a lot to learn.

I described what I needed: 'Integrate HealthKit to read heart rate during workouts and save workout summaries. Handle the authorization flow and show appropriate UI if access is denied.'

Cursor generated the entire integration: HKHealthStore setup, authorization request with proper data types, heart rate streaming during active workouts, and workout session management. The code needed minor fixes for edge cases (what happens when the user revokes permission mid-workout?) but the foundation was solid.

The hardest part: HealthKit runs asynchronously and Apple Watch has strict background execution limits. Cursor helped with the async patterns, but debugging timing issues required Xcode's debugger. This is where AI assistance hits its limits — real-device debugging on watchOS is still a manual, patience-requiring process.

Lessons Learned

AI + Xcode Is a Powerful Combo

Cursor generates the code, Xcode validates it. The instant feedback from Xcode's compiler catches issues that AI misses — wrong API signatures, deprecated methods, and type mismatches. The two tools complement each other perfectly.

Platform Knowledge Still Matters

AI can write SwiftUI, but understanding Apple's guidelines — Human Interface Guidelines, app lifecycle, background limits — requires reading documentation. The AI writes the code; you need to know what code should be written.

Start Simpler Than You Think

My first version was just a list of exercises with a timer. No HealthKit, no complications, no fancy animations. Getting the simplest version running on a real watch was incredibly motivating and taught me the deployment workflow.

Web Developers Have an Advantage

SwiftUI's declarative model, state management, and component composition map directly to React patterns. If you think in components and state, SwiftUI will feel familiar. AI tools leverage this similarity well when you mention your background.

More Cursor resources

On this page