RORK LABJP
TOOLING — Rork's developer repos keep moving: rork-xcode was updated on July 16, rork-device on July 15, and rork-plist on July 13OPUS46 — Claude Opus 4.6 is live in Rork, and Rork Max is built to assemble apps on top of Claude CodeSIM — A cloud iOS simulator runs in the browser, with one click to install on a device and two clicks to publish to the App StoreMAX — Rork Max emits pure Swift rather than React Native, reaching iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and even iMessageNATIVE — That opens up HealthKit, ARKit and LiDAR, NFC, Dynamic Island, Live Activities, 3D through Metal, and on-device inference with Core MLSEED — Rork raised a $15M seed led by Left Lane Capital, with Peak XV and a16z Speedrun joining the roundTOOLING — Rork's developer repos keep moving: rork-xcode was updated on July 16, rork-device on July 15, and rork-plist on July 13OPUS46 — Claude Opus 4.6 is live in Rork, and Rork Max is built to assemble apps on top of Claude CodeSIM — A cloud iOS simulator runs in the browser, with one click to install on a device and two clicks to publish to the App StoreMAX — Rork Max emits pure Swift rather than React Native, reaching iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and even iMessageNATIVE — That opens up HealthKit, ARKit and LiDAR, NFC, Dynamic Island, Live Activities, 3D through Metal, and on-device inference with Core MLSEED — Rork raised a $15M seed led by Left Lane Capital, with Peak XV and a16z Speedrun joining the round
Articles/Dev Tools
Dev Tools/2026-03-20Advanced

Build a Complete Fitness Tracker with Rork Max — HealthKit, Apple Watch, and Widget Integration

A comprehensive tutorial on building a fitness tracker app with Rork Max that integrates HealthKit, Apple Watch, and Home Screen widgets. From architecture design to App Store submission.

Rork Max229HealthKit5Apple Watch3Widget2FitnessSwiftUI63iOS109Native Development2Advanced Tutorial

What You'll Learn

Fitness trackers consistently rank among the top-performing categories on the App Store. Step counters, heart rate monitors, workout recorders, sleep analysis — building these features natively typically requires deep expertise across three Apple frameworks: HealthKit, WatchKit, and WidgetKit.

With Rork Max, you can integrate all three frameworks using natural language prompts. This tutorial walks you through designing and implementing an iPhone app, an Apple Watch companion, and a Home Screen widget as a single project — all the way to App Store submission.

Prerequisites: You should be comfortable with Rork Max basics and have built at least one app with it before. No prior experience with HealthKit or Apple Watch development is needed.

What we're building:

  • iPhone: Dashboard screen with steps, calories, heart rate, and sleep score
  • Apple Watch: Real-time workout recording with complication
  • Widget: Today's activity ring on the Home Screen

Setup and Requirements

What You Need

  • Rork Max account (Max plan at $200/month recommended)
  • Apple Developer Program ($99/year — required for App Store publishing)
  • iPhone + Apple Watch physical devices (HealthKit has limitations in the simulator)

Getting Started with Rork Max

Rork Max uses a cloud Mac fleet for native compilation, so you don't need Xcode installed locally. Head to rork.com/max and create a new project.

HealthKit Entitlements

Apps that use HealthKit require explicit entitlement configuration in the Apple Developer Portal. When you tell Rork Max to include health features, it automatically configures Info.plist and Entitlements for you.


Architecture and Design

System Overview

Our fitness tracker consists of three layers that communicate through shared data stores.

┌──────────────────────────────────────────────┐
│                 WidgetKit                     │
│     Home Screen Widget (Activity Ring)        │
├──────────────────────────────────────────────┤
│           iPhone App (SwiftUI)                │
│  Dashboard / History / Settings / HealthKit   │
├──────────────────────────────────────────────┤
│        Apple Watch App (WatchKit)             │
│  Workout Recording / Complication             │
└──────────────────────────────────────────────┘
          ↕ App Group (Shared Data) ↕
       HealthKit Store (Apple-managed)

Data Flow

When a workout is recorded on Apple Watch, data is saved to the HealthKit Store. The iPhone app reads the latest data from HealthKit and displays it on the dashboard. The widget reads aggregated data shared via App Group.

Prompt Strategy

When building complex multi-target apps with Rork Max, the best practice is to add features incrementally:

  1. Start with the iPhone app's base UI
  2. Add HealthKit data reading
  3. Add the Apple Watch target
  4. Add the widget target

Trying to do everything in a single prompt often leads to build errors as the AI struggles with the complexity.


Step-by-Step Implementation

Step 1: Build the iPhone App Base UI

Start with a prompt that defines the dashboard structure.

Create a fitness tracker app.
 
[iPhone App Screens]
1. Dashboard (Tab 1)
   - Today's steps (large number + circular progress ring)
   - Calories burned (ring display)
   - Heart rate (latest value + small line chart)
   - Sleep score (bar chart + rating text)
 
2. History (Tab 2)
   - Weekly/monthly step trend graph
   - Daily detail data list
 
3. Settings (Tab 3)
   - Change step goal
   - Toggle notifications
   - HealthKit connection status
 
[Design Requirements]
- Dark mode fitness UI
- Circular progress similar to Apple's Activity Rings
- SF Symbols for icons
- SwiftUI Charts framework for graphs

Rork Max will generate a SwiftUI-based three-tab app. Preview it in the streaming simulator to verify the layout.

Step 2: Integrate HealthKit

Add HealthKit data reading with the next prompt.

Integrate HealthKit into the app.
 
[Data to Read]
- Steps (HKQuantityType.stepCount) — today's total
- Calories (HKQuantityType.activeEnergyBurned) — today's total
- Heart rate (HKQuantityType.heartRate) — latest + last 24h samples
- Sleep (HKCategoryType.sleepAnalysis) — last night's duration
 
[Requirements]
- Create a HealthKitManager class to centralize data fetching
- Show HealthKit authorization request on first launch
- Use background delivery for step count updates
- Show placeholders when data is unavailable
- Set appropriate NSHealthShareUsageDescription

The key component Rork Max generates is the HealthKitManager. Here's the expected structure:

// HealthKitManager.swift — Core data fetching class
import HealthKit
 
class HealthKitManager: ObservableObject {
    let healthStore = HKHealthStore()
 
    @Published var todaySteps: Int = 0
    @Published var todayCalories: Double = 0
    @Published var latestHeartRate: Double = 0
    @Published var sleepHours: Double = 0
 
    // Request HealthKit authorization
    func requestAuthorization() async throws {
        let readTypes: Set<HKObjectType> = [
            HKQuantityType(.stepCount),
            HKQuantityType(.activeEnergyBurned),
            HKQuantityType(.heartRate),
            HKCategoryType(.sleepAnalysis)
        ]
        try await healthStore.requestAuthorization(
            toShare: [], read: readTypes
        )
    }
 
    // Fetch today's step count
    func fetchTodaySteps() async {
        let stepsType = HKQuantityType(.stepCount)
        let today = Calendar.current.startOfDay(for: Date())
        let predicate = HKQuery.predicateForSamples(
            withStart: today, end: Date()
        )
 
        let query = HKStatisticsQuery(
            quantityType: stepsType,
            quantitySamplePredicate: predicate,
            options: .cumulativeSum
        ) { _, result, _ in
            DispatchQueue.main.async {
                self.todaySteps = Int(
                    result?.sumQuantity()?
                        .doubleValue(for: .count()) ?? 0
                )
            }
        }
        healthStore.execute(query)
    }
}
 
// Expected output:
// todaySteps = 8432 (actual step count from HealthKit)
// todayCalories = 342.5 (active energy burned)

Step 3: Add the Apple Watch Companion App

Add the watchOS target with this prompt:

Add an Apple Watch companion app.
 
[Watch App Features]
1. Workout recording screen
   - Workout type selection (Running/Walking/Cycling)
   - Start/Pause/Stop buttons
   - Real-time heart rate, calories, and elapsed time
   - Use HKWorkoutSession for accurate workout data
 
2. Today's activity screen
   - Steps + calories circular progress
   - Same goal values as the iPhone app
 
3. Complication
   - CircularGauge style showing current step count
 
[Technical Requirements]
- WatchConnectivity for bidirectional iPhone sync
- Extended Runtime Session for background workouts
- Digital Crown to scroll through workout types

The core of the Watch app is the WorkoutManager that handles real-time workout recording:

// WorkoutManager.swift — Workout session management
import HealthKit
import WatchKit
 
class WorkoutManager: NSObject, ObservableObject {
    let healthStore = HKHealthStore()
    var workoutSession: HKWorkoutSession?
    var workoutBuilder: HKLiveWorkoutBuilder?
 
    @Published var heartRate: Double = 0
    @Published var calories: Double = 0
    @Published var elapsedTime: TimeInterval = 0
    @Published var isActive = false
 
    func startWorkout(type: HKWorkoutActivityType) async throws {
        let config = HKWorkoutConfiguration()
        config.activityType = type
        config.locationType = .outdoor
 
        workoutSession = try HKWorkoutSession(
            healthStore: healthStore,
            configuration: config
        )
        workoutBuilder = workoutSession?.associatedWorkoutBuilder()
        workoutBuilder?.dataSource = HKLiveWorkoutDataSource(
            healthStore: healthStore,
            workoutConfiguration: config
        )
 
        workoutSession?.delegate = self
        workoutBuilder?.delegate = self
 
        let start = Date()
        workoutSession?.startActivity(with: start)
        try await workoutBuilder?.beginCollection(at: start)
        isActive = true
    }
 
    func endWorkout() async throws {
        workoutSession?.end()
        try await workoutBuilder?.endCollection(at: Date())
        try await workoutBuilder?.finishWorkout()
        isActive = false
    }
}
 
// Expected output:
// After starting a workout, heart rate and calories update in real time
// heartRate = 142.0 (bpm)
// calories = 87.3 (kcal)
// elapsedTime = 1200.0 (seconds = 20 minutes)

Step 4: Add Home Screen Widgets

Finally, add the widget extension:

Add Home Screen widgets.
 
[Widget Specs]
- Sizes: Small (2x2) and Medium (4x2)
- Small: Today's steps + circular progress ring
- Medium: Steps + calories + heart rate side by side
 
[Technical Requirements]
- App Group for sharing data with the iPhone app
- TimelineProvider that refreshes every 15 minutes
- Fitness-themed accent color (green tones)
- Widget tap opens iPhone app dashboard via DeepLink

The widget's core is the TimelineProvider that reads data through App Group:

// FitnessWidget.swift — Widget timeline provider
import WidgetKit
import SwiftUI
 
struct FitnessEntry: TimelineEntry {
    let date: Date
    let steps: Int
    let stepGoal: Int
    let calories: Double
    let heartRate: Double
}
 
struct FitnessTimelineProvider: TimelineProvider {
    let defaults = UserDefaults(
        suiteName: "group.com.yourapp.fitness"
    )
 
    func getTimeline(
        in context: Context,
        completion: @escaping (Timeline<FitnessEntry>) -> Void
    ) {
        let steps = defaults?.integer(forKey: "todaySteps") ?? 0
        let goal = defaults?.integer(forKey: "stepGoal") ?? 10000
        let cal = defaults?.double(forKey: "todayCalories") ?? 0
        let hr = defaults?.double(forKey: "latestHeartRate") ?? 0
 
        let entry = FitnessEntry(
            date: Date(), steps: steps,
            stepGoal: goal, calories: cal, heartRate: hr
        )
 
        let next = Calendar.current.date(
            byAdding: .minute, value: 15, to: Date()
        )!
        let timeline = Timeline(
            entries: [entry], policy: .after(next)
        )
        completion(timeline)
    }
 
    // ... placeholder, snapshot omitted
}
 
// Expected output:
// Home Screen shows activity ring with current steps
// Updates every 15 minutes with latest data
// Tapping opens the iPhone app

Advanced Patterns

Pattern 1: Automatic Workout Detection

Apple Watch includes motion detection via CMMotionActivityManager. Add this prompt to Rork Max to auto-detect when users start running:

Use CMMotionActivityManager to detect when the user starts running
and send a notification asking "Start a workout?"

Pattern 2: Weekly Summary Notifications

Send a weekly activity summary every Monday morning:

Every Monday at 9 AM, send a local notification with last week's
exercise summary (total steps, average heart rate, workout count).

Pattern 3: Data Export

Let users export their health data as CSV:

Add an "Export Data" button in Settings that exports the last 30 days
of steps, calories, and sleep data as a CSV file via the share sheet.

Troubleshooting

HealthKit Authorization Gets Rejected

If users deny HealthKit access, HKAuthorizationStatus becomes .sharingDenied. Show a UI that guides them to Settings. Tell Rork Max: "Show a button to open Settings when HealthKit permission is denied."

Data Sync Delay Between iPhone and Apple Watch

WatchConnectivity's transferUserInfo isn't always immediate. Use sendMessage for real-time data and transferUserInfo for background sync.

Widget Not Updating

WidgetKit timeline updates are system-managed, so 15-minute intervals aren't exact. Call WidgetCenter.shared.reloadAllTimelines() from the iPhone app whenever HealthKit data changes to force a refresh.

Build Error: App Group Mismatch

All three targets (iPhone, Watch, Widget) must use the same App Group ID. Tell Rork Max explicitly: "Set the App Group ID to group.com.yourapp.fitness for all targets."

Workout Session Stops in Background

watchOS requires Extended Runtime Session for background workout recording. Rork Max configures this automatically, but if it fails, add the prompt: "Enable Extended Runtime Session for HKWorkoutSession."


Publishing and Monetization

App Store Review Considerations

Apps using HealthKit face stricter Apple review. Key points:

  1. NSHealthShareUsageDescription must clearly state why you need the data (e.g., "This app uses HealthKit to display your steps and heart rate")
  2. Request only the minimum data types needed — requesting unnecessary types leads to rejection
  3. Privacy policy must explicitly cover HealthKit data handling
  4. Don't transmit HealthKit data to external servers without clear disclosure

Revenue Models

Common monetization strategies for fitness apps include:

  • Freemium: Basic features (steps, calories) free; detailed analytics, Apple Watch support, and CSV export as premium
  • Subscription: $4.99/month or $29.99/year using Rork Max's StoreKit 2 integration
  • One-time purchase: Premium features for $9.99

ASO (App Store Optimization)

The fitness category is highly competitive. Target niche keywords beyond "step counter" and "heart rate" — phrases like "HealthKit widget," "Apple Watch workout tracker," and "fitness dashboard iOS" can help you rank for less competitive terms.


Wrapping Up

This tutorial covered the complete process of building a fitness tracker that integrates HealthKit, Apple Watch, and Home Screen widgets using Rork Max.

Key takeaways:

  • Incremental prompt design: Build iPhone → HealthKit → Watch → Widget in stages
  • Centralized data with HealthKitManager: Steps, calories, heart rate, and sleep managed in one place
  • WatchConnectivity for bidirectional sync: Real-time data between iPhone and Apple Watch
  • App Group for widget data sharing: 15-minute timeline updates on the Home Screen
  • Monetization: Freemium + StoreKit 2 subscriptions

The power of Rork Max lies in turning what used to be weeks of multi-platform development into a series of well-crafted prompts. For more on the individual components, check out our guides on Apple Watch app development, widget creation, and HealthKit basics.

Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Dev Tools2026-03-26
Building Apple Watch Apps with Rork Max — A Complete watchOS Companion App Guide
Learn how to build Apple Watch (watchOS) companion apps using Rork Max. This guide covers SwiftUI-based WatchKit development, iPhone communication, HealthKit integration, and complication implementation.
Dev Tools2026-07-13
Losing HealthKit Data on Incremental Sync — Designing HKQueryAnchor Persistence
When step or sleep data double-counts or goes missing on incremental HealthKit sync, the root cause is usually HKQueryAnchor persistence. Here is a working Swift design that handles newAnchor and deletedObjects correctly and stays consistent across reinstalls and background updates.
Dev Tools2026-07-06
Migrating Rork Max SwiftUI to @Observable: Narrowing the Re-renders ObservableObject Was Spreading
Rork Max tends to generate SwiftUI apps built on ObservableObject and @Published, where a single state change re-evaluates every subscribing view. Moving to the Observation framework's @Observable narrows invalidation to the property level. Here is the migration path, plus the view-body execution counts I measured in Instruments before and after.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →