WorkoutKit

RSS for tag

The WorkoutKit framework provides the ability to create, preview, and schedule planned workouts for the Workout app on Apple Watch.

Posts under WorkoutKit tag

33 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Workouts created with SingleGoalWorkout do not have a display name, as opposed to workouts created with CustomWorkout. Why is that?
With CustomWorkout, I can assign a name (displayName) to workouts, which also appears in the Workout app. Unfortunately, this parameter is missing for common workouts such as SingleGoalWorkout. Is there a reason for this? I find it inconvenient when the name is missing CustomWorkout init(activity: HKWorkoutActivityType, location: HKWorkoutSessionLocationType, displayName: String?, warmup: WorkoutStep?, blocks: [IntervalBlock], cooldown: WorkoutStep?) SingleGoalWorkout init(activity: HKWorkoutActivityType, location: HKWorkoutSessionLocationType, swimmingLocation: HKWorkoutSwimmingLocationType, goal: WorkoutGoal)
0
0
418
Dec ’23
First step in WorkoutKit
Hi there, I'm new here, looking for a step-by-step tutorial that will help me to achieve my first step. https://developer.apple.com/documentation/workoutkit/customizing-workouts-with-workoutkit downloaded the WorkoutKit sample file. try to run, and connect to my account and team but get an error to connect a device. Your team has no devices from which to generate a provisioning profile. Connect a device to use or manually add device IDs in Certificates, Identifiers & Profiles. https://developer.apple.com/account/ " I logged in to my web account but didn't find any device IDs in Certificates, Identifiers & Profiles section
0
0
474
Dec ’23
How to increase the nmea logging period
Hi experts, I got an Ultra2 a while ago and has been using it on walking / running exercise. Recently I came across to this apple site: debug profile and I'm curious about what I would get during the exercise. So I follow the instruction and install the location services profile. After getting the sysdiagnose report, I try to get location related information from it. And it seems that the log from "locationd" and "gpsd" are what I'm looking for. But when I try to look into the nmea information, I found out the sysdiagnose only provide around 10-15 mins of nmea data. For example, let's say I have a walking exercise from 0900 - 1000, but I can only see nmea data from 0945 - 1000. The data from 0900 to 0945 can't be found in the sysdiagnose. Not sure if's the limitation or any setting I can change to increase the logging period? Thanks.
0
0
448
Dec ’23
Need help with Customizing workouts with WorkoutKit
Please reference the Sample Planner app which can be found at the below link. https://developer.apple.com/documentation/WorkoutKit/customizing-workouts-with-workoutkit. In WorkoutStore.swift, all of the values are hard coded. I would like to turn them into variables stored in @EnvironmentObject (WorkoutStoreValue). With the below code, using "singleRunStartDelay" as a trial, I can get that variable passed to the WorkStore struct only when the app is first opened, however, I have not been able to get it changed in realtime. I need help with changing the WorkoutStore struct to have the values updated in realtime. I have tried changing the func from static but that gives an error (Instance member 'createSingleRunWorkout' cannot be used on type 'WorkoutStore'; did you mean to use a value of this type instead?) I'm now learning Xcode/SwiftUI. I have been stuck for about four day trying many different ideas. Thanks // Copyright © 2024 Apple. All rights reserved. /* The structure that returns running workout compositions. */ import HealthKit import WorkoutKit import SwiftUI import Foundation struct WorkoutStore{ @EnvironmentObject var workoutStoreValue: WorkoutStoreValue static func createSingleRunWorkout() -> CustomWorkout { let getReadyStep = WorkoutStep(goal: .open) //fixed to .open let singleRunDelay = WorkoutStoreValue.shared.singleRunStartDelay var onYourMarkStep = IntervalStep(.work) onYourMarkStep.step.goal = .time(Double(singleRunDelay), .seconds) //you have this much time to start var runStep = IntervalStep(.work) runStep.step.goal = .distance(100, .meters) //hard coded for now. Need to insert distance variable here runStep.step.alert = .speed(3...4, unit: .metersPerSecond, metric: .current) // Would like to insert alert variables here var block = IntervalBlock() block.steps = [ onYourMarkStep, runStep ] block.iterations = 1 //fixed at 1. Would like to insert as a variable return CustomWorkout(activity: .running, location: .outdoor, displayName: "Single run mode", warmup: getReadyStep, blocks: [block]) } }
2
0
451
Jun ’24
Can I add a custom workout for my companion app?
Hello fellow developers, I've recently developed a workout companion watch app for iOS. However, I'm now have a task of implementing custom workouts for my app. I've come across a video demonstrating how to create and schedule custom workouts for the watch app, which I believe will be incredibly helpful for my project. Video Link: Creating Custom Workouts for iOS Watch App If anyone knows of any additional resources, such as articles or videos, that further explores this topic, I would greatly appreciate it if you could share them with me. Thank you for your assistance! Best regards, Pranit Bhogale
0
0
359
Apr ’24
How to generate .workout files
The WWDC23 session number 10016 is referring to a way to generate .workout files (timecode 09:43) in both binary and JSON format. Unfortunately, the API seems to have changed: CustomWorkoutComposition renamed to CustomWorkout .dataRepresentation disappeared Ideally I would like to generate .workout files directly in JSON format but there is no specifications published and no documentation to generate them. Any idea where I should look?
1
0
343
Jun ’24
Remote device unreachable
Hello, I am using the project from https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/building_a_multidevice_workout_app The workout is starting on the watch and I can see the metrics, but it seems the mirroring with the phone is not working, I am getting this errors [mirroring] <HKWorkoutSession:0x600002c10100 57C340BA-2AA9-4477-9AC8-181698A526A5 running [Primary]>: Failed to send data to remote session with error: Error Domain=com.apple.healthkit Code=300 "Remote device is unreachable" UserInfo={NSLocalizedDescription=Remote device is unreachable, NSUnderlyingError=0x600000c53b70 {Error Domain=RPErrorDomain Code=-6727 "kNotFoundErr ('rapport:rdid:PairedCompanion' not found)" UserInfo={cuErrorDesc=kNotFoundErr ('rapport:rdid:PairedCompanion' not found), cuErrorMsg='rapport:rdid:PairedCompanion' not found, NSLocalizedDescription=kNotFoundErr ('rapport:rdid:PairedCompanion' not found)}}} Does anybody else has this issue? Thank you
0
0
302
May ’24
How to add "Estimated Time in Each Heart Rate Zone" info to my custom HKWorkout when viewed in Apple Fitness app?
Hello, I’m currently developing a fitness app for watchOS that lets a user to manually set a desired heart rate target zone (enter numbers representing the lower and upper boundaries) and start a workout (right now it’s only “Other” type). After that my app monitors user’s heart rate and alerts them when they’re out of zone. When user ends the workout, the info about this workout appears on “Fitness” iOS app, and user can see the workout data like Workout Time, Active and Total Calories, Avg. Heart Rate. Also user can see Heart Rate chart with info how their heart rate was changing during a workout (see the Figure 1). Now to the question. When user clicks “Show More” button above the Heart Rate chart, they can see the same Heart Rate chart and another one, with Post-Workout Heart Rate (see the Figure 2). But there is no “Estimated time in each heart rate zone” as one can see in the workout’s details that were recorded from Apple’s workout (watchOS “Workout” app, for a workout of “Other” type as well). Please see the Figure 3. The question is: is it possible to add “Estimated time in each heart rate zone” to workout recorded via my third-party app so it would look like on the Figure 3 in "Fitness" iOS app, and if it's possible, what steps should I undertake to implement this ? Thanks in advance! I posted the screenshots in the replies to the post, because otherwise I was not able to submit a post ("sensitive language" warning, I suspect it's because of the ids in the attached screenshot's urls)
1
0
412
May ’24
Which workouts have a GPS track?
The session Build custom swimming workouts with WorkoutKit mentions Outdoor activities supporting distance goals and lists: Cycling Running Hiking Walking Swimming Wheelchair walk + run And new: Golf Rowing Downhill skiing Snowboarding Lacrosse Hockey Disc Sports Skating Paddle sports Soccer American football Australian football Rugby Cross country skiing I know the previous 6 have GPS tracks saved with the workout in Health. Do all of the other ones now also save the GPS track to Health? If not all of them, which do?
1
0
320
Jun ’24
Workout validation and Scheduler logic
Hey folks, a couple of questions regarding WorkoutKit: What happened to validation errors? They are mentioned in the WWDC23 video, but no longer are present in the API. It seems a fatal error is thrown if the workout fails validation (for example setting a negative distance in a workout goal). What is the logic of the WorkoutScheduler, if we try to add more workouts than is allowed? If the limit is 50, what happens when we try to add a 51st? Are workouts de-queued based on date or anything? API documentation is very sparse Do completed workouts and workouts with a scheduled date in the past stay in the WorkoutScheduler? Are we responsible for removing these? I guess my overall question regarding the WorkoutScheduler is, what are we responsible for managing and what is handled gracefully for us. None of these answers seem to be openly available, but if anyone know anecdotally or even better from the WorkoutKit team, I'd be very grateful! Thanks!
0
0
56
3d