Build a workout app for Apple Watch

RSS for tag

Build a workout app for Apple Watch

Posts under wwdc21-10009 tag

16 Posts

Post

Replies

Boosts

Views

Activity

Apple Watch Health App not launching
Hello. My Apple Watch Health App is not launching is stuck on the loading screen forever. In the debug console, This message is displayed. `SwiftUI/EnvironmentObject.swift:70: Fatal error: No ObservableObject of type WorkoutManager found. A View.environmentObject(_:) for WorkoutManager may be missing as an ancestor of this view. 2022-04-19 10:27:58.865727-0400 FitnessFriend WatchKit Extension[65428:475974] SwiftUI/EnvironmentObject.swift:70: Fatal error: No ObservableObject of type WorkoutManager found. A View.environmentObject(_:) for WorkoutManager may be missing as an ancestor of this view. (lldb)  If anybody could help, it would be greatly appreciated.
0
0
628
Apr ’22
How do I measure/get a heartbeat at thousands of seconds from Apple Watch?
Can Apple Watch provide complete data on the heartbeat for thousands of seconds during the workout or when using the "Breathe" app? When I exported data from Apple Health it shows the following data. The rows 195, 196 & 197 are measurements taken through the "Breathe" app. Thank you for your answers,
4
0
1.7k
Mar ’22
How to display Step Count in a Watch App?
I am trying to display the steps of a user to a metrics view screen in an apple watch. Here is how I try to get the steps: KQuantityType.quantityType(forIdentifier: .stepCount):         let stepCount = HKUnit.meter()         self.stepCount = statistics.sumQuantity()?.doubleValue(for: stepCount) ?? 0         print("step count: \(self.stepCount ?? 0)") Where stepCount is a published variable. I then try to display the steps: Text("\(workoutManager.stepCount!) steps") I am not able to see the steps in a log when I try to print or through Text....any ideas on how to do this?
0
0
700
Mar ’22
HKSwimmingStrokeStyle in Fitness app
If I use the Apple training app for indoor swim workouts, I can see the distance by each swimming stroke style later in the Fitness app. However, if I build my own swim app, the distance by stroke style is not listed. What do I have to add, to have it listed there? The information are saved correct in the HKWorkoutEvent array in the workout.
1
0
1.4k
Dec ’21
What is the frequency at which you can access data with your app in background?
I’m trying to understand how often I can get updates on stuff like Heart Rate , Oxygen Saturation and movement. I'm building a third party app that detects sleep phases so I need it to monitor all night (5-8 hours) and get an update at least every minute. I don’t think I can use the HKWorkoutType class/subclass since it’s not really a workout, and I was told Apple might reject my application. I understand I should be able to get something via enableBackgroundDelivery Another post here suggests to use ExtendedRuntimeSessions Can anyone give me some directions on the feasibility? Is there any way to access Heart Rate directly, without using the WorkoutSession classes? PS What about movement? Is accessing the accelerometer easier?
1
0
1.4k
Dec ’21
Swifui, IOS15, Xcode 13 Sharing core data with Watch
I am trying to share the standard “Item” database supplied when you check the Core Data box when building an app. I have gotten to the point where I am using a shared Persistence file and data model between the IOS device and the Watch. I can add data from both sides but it appears that the data is not “syncing”. I am using a shared app group id in the Persistence file. why isn’t it syncing? any ideas would be appreciated.
1
0
563
Dec ’21
SwiftUI render wrong size on old devices like Apple Watch Series 4
Problem: SwiftUI render wrong size on old device like Apple Watch Series 4. The height was be cut, not well render as series 6 or simulator. Check the screenshots. BTW: But it works well both on watch series 6 real device or simulator. Reproduce: Download “Build a Workout App for Apple Watch”, run the code on a real device of watch series 4 https://developer.apple.com/videos/play/wwdc2021/10009/ On Watch4-44 mm (first line be clip) On Simulator or watch 6.
0
0
1k
Sep ’21
Value of type 'Measurement<UnitEnergy>' has no member 'formatted'
I have just decided I want to make a watch app and am trying to familiarize myself with Xcode and Swift. So I decided to follow the Workout app for watchOs tutorial and the tutorial used this block of code. Text(      Measurement(       value: 47,       unit: UnitEnergy.kilocalories      ).formatted(        .measurement(         width: .abbreviated,         usage: .workout,         numberFormat: .numeric(          precision: .fractionLength(0)         )        )       )     ) However when I try to use this code I get the following error. Value of type 'Measurement<UnitEnergy>' has no member 'formatted' Im using XCode Version 12.5.1 Any help is appreciated!
0
0
589
Aug ’21
watchOS 8 Always On display APIs
I'm working on updating my Apple Watch workout app to support always on display low frequency modes in watchOS 8. I'm using the sample project (https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/build_a_workout_app_for_apple_watch) as a guide but am hitting some problems with getting the workout metrics updating while in the Always On state. The timer correctly hides the sub seconds but the time and other health metrics do not update while the Always On mode is toggled in the simulator. This sample project used to work during the first Xcode beta but is no longer working. Does anyone know if there are any new requirements aside from using the TimelineView? Thanks for the help!
2
0
1.8k
Aug ’21
Get active Window or Process Title Programatically
Hi Team, I used below code to get active window details. but unable to find title of it. Can you please help me on it. C# based code in Mac var foreground_app = NSWorkspace.SharedWorkspace.FrontmostApplication; foreground_app contains active application details. but i am not able to identify active window details . guide me which property or function i need to use to get active window title details EX: i opened Numbers, below condition will trigger if(foreground_app.LocalizedName.ToLower().Contains("numbers")) { /// }
0
0
1.3k
Jul ’21
CLLocationManager didUpdateLocations not updating while Watch dims
I'm developing a workout app and the app uses routeBuilder to save the workout route along with workout data. The app did as expected (retrieves and saves GPS data) when app is in foreground mode and even in background mode when Apple Watch display is ON ... the problem is when the watch enters the dim state (blur on Always On) then GPS data is received 10-15 more seconds and after that the app stops receiving updates until display is ON again. Background Mode - Location Updates and Workout Processing capabilities are ON , allowsBackgroundLocationUpdates is true, Location When In Use permission is granted. App works fine on simulator. The previous behavior is on an Apple Watch 6, 44mm WatchOS 7.5 (Watch only app)
1
0
1.2k
Jul ’21
Why HKObjectType instead of HKQuantityType?
The requestAuthorization method in WorkoutManager wants to read HR, energy, distance and "activity" information all of which are HKQuantityTypes. //The quantity types to read from the health store let typesToRead: Set = [ HKQuantityType.quantityType(forIdentifier: .heartRate)!, HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned)!, HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning)!, HKQuantityType.quantityType(forIdentifier: .distanceCycling)!, HKObjectType.activitySummaryType() ] The documentation for HKObjectType states: The HKObjectType class is an abstract class. You should never instantiate an HKObjectType object directly. Instead, you always work with one of the following concrete subclasses: ... HKQuantityType Replacing HKObjectType.activitySummaryType() with HKQuantityType.activitySummaryType() in the above code doesn't appear to cause any issues with the app. Intuitively, it should work exactly the same since HKQuantityType (being a concrete subclass of HKObjectType) inherits directly from HKObjectType. Is my understanding correct or have I missed something fundamental? If my thinking is correct, why is HKObjectType used in the sample code when all of the other set elements use the HKQuantityType subclass?
0
0
1k
Jun ’21
unable to check for update
I am trying to pair a new apple watch I got, iwatch 3 to my iphone 11 pro max and it keeps saying I am not connected to the internet which of course I am
Replies
0
Boosts
0
Views
887
Activity
May ’22
Apple Watch Health App not launching
Hello. My Apple Watch Health App is not launching is stuck on the loading screen forever. In the debug console, This message is displayed. `SwiftUI/EnvironmentObject.swift:70: Fatal error: No ObservableObject of type WorkoutManager found. A View.environmentObject(_:) for WorkoutManager may be missing as an ancestor of this view. 2022-04-19 10:27:58.865727-0400 FitnessFriend WatchKit Extension[65428:475974] SwiftUI/EnvironmentObject.swift:70: Fatal error: No ObservableObject of type WorkoutManager found. A View.environmentObject(_:) for WorkoutManager may be missing as an ancestor of this view. (lldb)  If anybody could help, it would be greatly appreciated.
Replies
0
Boosts
0
Views
628
Activity
Apr ’22
How do I measure/get a heartbeat at thousands of seconds from Apple Watch?
Can Apple Watch provide complete data on the heartbeat for thousands of seconds during the workout or when using the "Breathe" app? When I exported data from Apple Health it shows the following data. The rows 195, 196 & 197 are measurements taken through the "Breathe" app. Thank you for your answers,
Replies
4
Boosts
0
Views
1.7k
Activity
Mar ’22
How to display Step Count in a Watch App?
I am trying to display the steps of a user to a metrics view screen in an apple watch. Here is how I try to get the steps: KQuantityType.quantityType(forIdentifier: .stepCount):         let stepCount = HKUnit.meter()         self.stepCount = statistics.sumQuantity()?.doubleValue(for: stepCount) ?? 0         print("step count: \(self.stepCount ?? 0)") Where stepCount is a published variable. I then try to display the steps: Text("\(workoutManager.stepCount!) steps") I am not able to see the steps in a log when I try to print or through Text....any ideas on how to do this?
Replies
0
Boosts
0
Views
700
Activity
Mar ’22
ANS - Autonomic nervous system
Hello How to get (ANS)- Autonomic nervous system data from apple watch? THX
Replies
1
Boosts
0
Views
1k
Activity
Feb ’22
HKSwimmingStrokeStyle in Fitness app
If I use the Apple training app for indoor swim workouts, I can see the distance by each swimming stroke style later in the Fitness app. However, if I build my own swim app, the distance by stroke style is not listed. What do I have to add, to have it listed there? The information are saved correct in the HKWorkoutEvent array in the workout.
Replies
1
Boosts
0
Views
1.4k
Activity
Dec ’21
What is the frequency at which you can access data with your app in background?
I’m trying to understand how often I can get updates on stuff like Heart Rate , Oxygen Saturation and movement. I'm building a third party app that detects sleep phases so I need it to monitor all night (5-8 hours) and get an update at least every minute. I don’t think I can use the HKWorkoutType class/subclass since it’s not really a workout, and I was told Apple might reject my application. I understand I should be able to get something via enableBackgroundDelivery Another post here suggests to use ExtendedRuntimeSessions Can anyone give me some directions on the feasibility? Is there any way to access Heart Rate directly, without using the WorkoutSession classes? PS What about movement? Is accessing the accelerometer easier?
Replies
1
Boosts
0
Views
1.4k
Activity
Dec ’21
Swifui, IOS15, Xcode 13 Sharing core data with Watch
I am trying to share the standard “Item” database supplied when you check the Core Data box when building an app. I have gotten to the point where I am using a shared Persistence file and data model between the IOS device and the Watch. I can add data from both sides but it appears that the data is not “syncing”. I am using a shared app group id in the Persistence file. why isn’t it syncing? any ideas would be appreciated.
Replies
1
Boosts
0
Views
563
Activity
Dec ’21
Receive error when attempting to use .listStyle() function.
I receive an error when using the .listStyle(.carousel) function in Xcode 12.5, that error being Cannot infer contextual base in reference to member 'carousel' What should I do?
Replies
4
Boosts
0
Views
2.1k
Activity
Nov ’21
Apple fitness app
Can you add sauna to the fitness activities?
Replies
2
Boosts
0
Views
719
Activity
Sep ’21
SwiftUI render wrong size on old devices like Apple Watch Series 4
Problem: SwiftUI render wrong size on old device like Apple Watch Series 4. The height was be cut, not well render as series 6 or simulator. Check the screenshots. BTW: But it works well both on watch series 6 real device or simulator. Reproduce: Download “Build a Workout App for Apple Watch”, run the code on a real device of watch series 4 https://developer.apple.com/videos/play/wwdc2021/10009/ On Watch4-44 mm (first line be clip) On Simulator or watch 6.
Replies
0
Boosts
0
Views
1k
Activity
Sep ’21
Value of type 'Measurement<UnitEnergy>' has no member 'formatted'
I have just decided I want to make a watch app and am trying to familiarize myself with Xcode and Swift. So I decided to follow the Workout app for watchOs tutorial and the tutorial used this block of code. Text(      Measurement(       value: 47,       unit: UnitEnergy.kilocalories      ).formatted(        .measurement(         width: .abbreviated,         usage: .workout,         numberFormat: .numeric(          precision: .fractionLength(0)         )        )       )     ) However when I try to use this code I get the following error. Value of type 'Measurement<UnitEnergy>' has no member 'formatted' Im using XCode Version 12.5.1 Any help is appreciated!
Replies
0
Boosts
0
Views
589
Activity
Aug ’21
watchOS 8 Always On display APIs
I'm working on updating my Apple Watch workout app to support always on display low frequency modes in watchOS 8. I'm using the sample project (https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/build_a_workout_app_for_apple_watch) as a guide but am hitting some problems with getting the workout metrics updating while in the Always On state. The timer correctly hides the sub seconds but the time and other health metrics do not update while the Always On mode is toggled in the simulator. This sample project used to work during the first Xcode beta but is no longer working. Does anyone know if there are any new requirements aside from using the TimelineView? Thanks for the help!
Replies
2
Boosts
0
Views
1.8k
Activity
Aug ’21
Get active Window or Process Title Programatically
Hi Team, I used below code to get active window details. but unable to find title of it. Can you please help me on it. C# based code in Mac var foreground_app = NSWorkspace.SharedWorkspace.FrontmostApplication; foreground_app contains active application details. but i am not able to identify active window details . guide me which property or function i need to use to get active window title details EX: i opened Numbers, below condition will trigger if(foreground_app.LocalizedName.ToLower().Contains("numbers")) { /// }
Replies
0
Boosts
0
Views
1.3k
Activity
Jul ’21
CLLocationManager didUpdateLocations not updating while Watch dims
I'm developing a workout app and the app uses routeBuilder to save the workout route along with workout data. The app did as expected (retrieves and saves GPS data) when app is in foreground mode and even in background mode when Apple Watch display is ON ... the problem is when the watch enters the dim state (blur on Always On) then GPS data is received 10-15 more seconds and after that the app stops receiving updates until display is ON again. Background Mode - Location Updates and Workout Processing capabilities are ON , allowsBackgroundLocationUpdates is true, Location When In Use permission is granted. App works fine on simulator. The previous behavior is on an Apple Watch 6, 44mm WatchOS 7.5 (Watch only app)
Replies
1
Boosts
0
Views
1.2k
Activity
Jul ’21
Why HKObjectType instead of HKQuantityType?
The requestAuthorization method in WorkoutManager wants to read HR, energy, distance and "activity" information all of which are HKQuantityTypes. //The quantity types to read from the health store let typesToRead: Set = [ HKQuantityType.quantityType(forIdentifier: .heartRate)!, HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned)!, HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning)!, HKQuantityType.quantityType(forIdentifier: .distanceCycling)!, HKObjectType.activitySummaryType() ] The documentation for HKObjectType states: The HKObjectType class is an abstract class. You should never instantiate an HKObjectType object directly. Instead, you always work with one of the following concrete subclasses: ... HKQuantityType Replacing HKObjectType.activitySummaryType() with HKQuantityType.activitySummaryType() in the above code doesn't appear to cause any issues with the app. Intuitively, it should work exactly the same since HKQuantityType (being a concrete subclass of HKObjectType) inherits directly from HKObjectType. Is my understanding correct or have I missed something fundamental? If my thinking is correct, why is HKObjectType used in the sample code when all of the other set elements use the HKQuantityType subclass?
Replies
0
Boosts
0
Views
1k
Activity
Jun ’21