Can't create energy goals in WorkoutKit

I can create WorkoutGoals of all kinds except .energy, but I can't find any indication of the conditions under which energy goals can be used.

No matter what I try, the response from supportsGoal is always false e.g.

CustomWorkout.supportsGoal(.energy(10, .kilojoules), activity: .running, location: .outdoor)

CustomWorkout.supportsGoal(.energy(10, .calories), activity: .cycling, location: .outdoor)

CustomWorkout.supportsGoal(.energy(10, .kilocalories), activity: .running, location: .outdoor)

For any combination I've tried, I get Not supported due to unsupportedGoal

Has anybody managed to successfully create energy goals?

Answered by DTS Engineer in 822928022

.energy goals are only supported in SingleGoalWorkout as of today, so it is as-designed that CustomWorkout.supportsGoal(.energy...) always returns false.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Accepted Answer

.energy goals are only supported in SingleGoalWorkout as of today, so it is as-designed that CustomWorkout.supportsGoal(.energy...) always returns false.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Thanks for your quick response, and for letting me know.

I've logged a feedback request for adding support for energy goals in CustomWorkout.

Can't create energy goals in WorkoutKit
 
 
Q