Track workouts with HealthKit on iOS and iPadOS
Asked on 07/01/2025
1 search
To track workouts with HealthKit on iOS and iPadOS, you can utilize the powerful workout APIs provided by HealthKit. Here's a brief overview of the process:
-
Run a Workout Session: You can use a workout session to track any activity on iPhone and iPad, similar to how it's done on Apple Watch. This involves creating a workout configuration, setting the activity type (e.g., running), and using the associated workout builder to save the workout in HealthKit. You can start by creating a workout configuration and setting its type to reflect the activity the person will perform, such as running, and set the location to outdoor. Then, create an HK workout session, pass in the configuration, and attach a data source. Call
Prepare
on the session and display a countdown before starting the workout. Track workouts with HealthKit on iOS and iPadOS. -
Get Session Metrics: During the workout, you can collect various health metrics. HealthKit allows you to pair with external devices like heart rate monitors to gather data. You can add these measurements as samples to the health database, which will automatically be passed to your live builder. Track workouts with HealthKit on iOS and iPadOS.
-
Recover from a Crash: In case of a crash, you can handle active workout recovery by using the app delegate to check if recovery is needed and continue the workout session. Track workouts with HealthKit on iOS and iPadOS.
-
Best Practices: Always use the Workout Builder API to create and save workouts to ensure the activity rings are updated. Request authorization only for the data types you need to avoid confusing users. Track workouts with HealthKit on iOS and iPadOS.
These steps will help you effectively track workouts using HealthKit on iOS and iPadOS.

Track workouts with HealthKit on iOS and iPadOS
Learn best practices for building a great workout experience for iOS. Review the life cycle of a workout session, explore the differences between workouts on Apple Watch and iPhone, and find out how to use Live Activities and Siri to pump up your app’s Lock Screen experience.

Get started with HealthKit in visionOS
Discover how to use HealthKit to create experiences that take full advantage of the spatial canvas. Learn the capabilities of HealthKit on the platform, find out how to bring an existing iPadOS app to visionOS, and explore the special considerations governing HealthKit during a Guest User session. You’ll also learn ways to use SwiftUI, Swift Charts, and Swift concurrency to craft innovative experiences with HealthKit.

What’s new in watchOS 11
Explore new opportunities on Apple Watch, including bringing Double Tap support to your watchOS app, making your Smart Stack widgets even more relevant and interactive, and displaying your iOS Live Activities in the Smart Stack.