feat(iOS): Add Apple Health workout route (GPX) sync support - #2341
rodrigosa7 wants to merge 2 commits into
Conversation
…--trailer "Co-authored-by: Junie <junie@jetbrains.com>"
|
Thanks @rodrigosa7. The shape is right: permission added, gated on Every point carries the same timestampCLLocation(..., timestamp: start)
The cause is upstream: The altitude is fabricated, and claims to be accuratealtitude: 0, horizontalAccuracy: 1, verticalAccuracy: 1
A route failure reports the workout as failedThe route block sits after The route is an enrichment, not part of the workout's success. Its own One process noteNo checks ran on this PR. |
…and error handling
|
Thanks for the detailed review, Ryan! I've implemented all the requested changes:
Regarding the altitude: I see that RoutePoint is currently lat/lon only. I agree that -1 is the right move for now to keep the data honest, but maybe we should look into extending the schema to store elevation in a future update! |
|
Reviewed at 152afb8. CI is 4/4 green including both compile legs, the description is accurate about what it does, and the HealthKit plumbing is mostly right. I want to hold this one anyway, because of what it writes. The blocking issue: the timestamps are invented// Interpolate timestamps across the workout's span, since RoutePoint is lat/lon only.
let ts = start.addingTimeInterval(duration * Double(i) / Double(max(points.count - 1, 1)))The comment is honest about what it is doing, and its premise is true as far as it goes: the stored type carries no time. But the recorder had the real times. So this is not reconstructing something that was never measured. It is re-inventing something that was measured, filtered, and then discarded one layer down. What ends up written is a route whose every segment implies identical pace. Apple's Fitness app, and every third-party HealthKit reader, computes speed and splits from route timestamps, so a run with a hill in it becomes a flat trace, permanently, in the user's health record. The distance NOOP writes separately stays correct, which makes it worse rather than better: the summary and the trace become two readouts of one workout that can disagree.
The repair belongs one layer down: put per-point time and accuracy into Two smaller things
Minor: the route builder is not discarded on the What is genuinely good
SuggestionSplit it in two. Land per-point time and accuracy in |
Summary
This PR implements workout route (GPX) synchronization from NOOP to Apple Health for outdoor activities.
Changes
HKSeriesType.workoutRoute()to HealthKit sharing permissions inHealthKitBridge.writeWorkoutsto load polyline data fromRouteStorefor GPS-enabled sports.HKWorkoutRouteBuilderto associate GPS points with theHKWorkoutobject.Verification
WhoopStoreandHealthKitBridgepatterns.StrandiOStarget.xcodebuild.Refs #2340