DEV Community

buildbyalex
buildbyalex

Posted on

Building an AI workout coach in SwiftUI: one-tap logging during the set, GPT-4o analysis after

Most people who track their training in a notes app lose the one thing that matters: set-by-set context. The note does not remember what you lifted last week, and generic gym trackers bury the screen in charts without ever telling you what to do next.

The brief for Body Forge was a coach in your pocket: clean tracking during the set, real analysis after it, and programmes that adapt as you progress. Here is how the native iOS app is put together.

During the set: show almost nothing

The workout screen is built for one hand and a sweaty thumb. It shows only:

  • last week's sets for this exercise;
  • a rest timer;
  • weight and reps;
  • one tap to log the set.

Everything else waits until the session is over. Between sets nobody wants to read a graph.

After the session: let the model read the whole workout

When the workout ends, the app sends a compact summary to GPT-4o: volume, intensity and progression compared with the last three weeks. The model writes a short, personal analysis with concrete changes for next time, for example: stalled on incline press three weeks in a row, deload to 80% next week.

The trick is what you send. Raw logs are noisy, so the app builds a small structured summary first. Simplified:

struct ExerciseSummary: Codable {
    let name: String
    let sets: [SetEntry]          // weight, reps, rest
    let topSetLast3Weeks: [Double]
    let volumeChange: Double      // vs. the previous session
}

struct WorkoutSummary: Codable {
    let date: Date
    let programme: String         // e.g. "Upper/Lower, week 4"
    let exercises: [ExerciseSummary]
    let avgHeartRate: Int?        // from HealthKit, if available
}
Enter fullscreen mode Exit fullscreen mode

The model gets numbers it can reason about, not a wall of text, and the answer comes back in about 10 seconds.

The rest of the stack

  • SwiftUI on iOS 17 and later;
  • Core Data locally with CloudKit sync, so history survives a new phone;
  • HealthKit for heart rate during the session;
  • a programme library: Upper/Lower split, full-body for beginners, custom blocks;
  • more than 200 exercises with video form demos;
  • Russian and English localisation.

The landing page

An App Store link does not explain why one tracker is better than a hundred others, and it does not rank in search. The app got its own bilingual site, bodyforges.com, in the same dark style with one goal per screen: go to the App Store. The first screen paints in about 0.7 seconds.

What we took from it

  • Design the in-workout screen for the worst moment. Tired, one hand, ten seconds of attention.
  • Summarise before you prompt. A structured summary gives better analysis than raw logs, and it is cheaper.
  • Make the advice concrete. "Deload to 80% next week" is useful, "keep pushing" is not.

Body Forge is live in the App Store. Full case: Body Forge case study. We build apps like this for small teams and founders, more on mobile app development.

Top comments (0)