This might be a silly question. Does anyone know if HealthKit is available for iPadOS 14? I see that it is now available for MacCatalyst 13.0+ in the documentation but iPadOS was not listed.
Thanks,
Casey
Post not yet marked as solved
Hello everyone,
I just started watching the WWDC21 Code Along "Build a Research and Care App, Part 1" and wanted to run the project in Xcode. However, when I clone the Repo with the recommended
git clone --recurse-submodule https://github.com/carekit-apple/WWDC21-RecoverApp.git command and open the project, I get the following error:
/WWDC21-RecoverApp/Recover Part 1/Recover.xcodeproj This Copy Files build phase contains a reference to a missing file 'ResearchKit.framework'.
/WWDC21-RecoverApp/ResearchKit only contains 2 files (CONTRIBUTING.md and LFS-Files).
I was wondering how I could get the project up and running and if there are additional steps to take, that I didn't see in the presentation / Github Readme.
Thanks!
Post not yet marked as solved
If a "Minimum Deployment Target" is updated to WatchOS7 on a product(iOS app with a companion watch app) that is already available on the App Store, watches running WatchOS6 will obviously no longer get updates.
However, what is the experience for a user who has a WatchOS6 (maybe they own a Series 2) connected to an iPhone with iOS14?
Will both the iPhone app and the Watch app stop getting updates?
Will the Watch app stop getting updates, but the iPhone app continue receiving them and we have to manage this?
Something else?
Thanks in advance!
Post not yet marked as solved
Hello all, this could surely be a newbie mistake but I'm unable to adopt this protocol to my class object I've created in a new project.
The Error: "Cannot find type 'OCKSurveyTaskViewControllerDelegate' in scope"
import CareKit
import CareKitUI
import CareKitStore
import ResearchKit
import UIKit
import os.log
final class CareFeedViewController: OCKDailyPageViewController, OCKTaskSurveyViewControllerDelegate {
}
However, I've been able to locate the 'OCKSurveyViewController.swift" file in the CareKit framework from SPM which has the protocol defined there, but I'm still unable to utilize it. Was the protocol only for demonstration purposes and not for use outside of the WWDC21 - CareKit Code Along?
Post not yet marked as solved
I've ran into an error with the insertRouteData function of the HKWorkoutRouteBuilder that I can't seem to find any information on. The error is "Unable to find location series 1A193D3B-AFF5-41D8-A967-B1BE08D9F543 during data insert.". It seems to only happen when trying to insert very long routes, in the most recent case it was a 5 hour bike ride with 5900 samples. I save all the route data in a sqlite table as backup and after checking out the data there isn't any red flags as to why it would not insert correctly. Has anyone seen this before and could offer some insight or point me in the right direction to find the source of the error?
Post not yet marked as solved
I developed an iPhone/Watch app with the single target setting (new method) for Watch app projects, which will be available from Xcode14. This app uses HealthKit to retrieve information such as step count and heart rate from healthcare. The watch app is not independent and requires the iPhone app (companion app).
Regarding the permission to access health care, i found some differences from the Old WatchApp Project (application project structure using WatchExtension when Xcode 13.4 or lower is used).
This does not occur in the iPhone simulator or watch simulator, but only on the actual device.
Both the iPhone app and watch app now display a dialog to allow access to health care
In the Old WatchApp Project, if access was granted in either app, the granted access is synchronized.
When checking the Health Care access status in the iPhone Settings App, permission settings for both the iPhone app and watch app are displayed independently.
Because each permission setting is independent, you can choose to allow access to the iPhone app but not to allow it to the watch app.
the Old WatchApp Project, permission settings for the iPhone app and watch app were synchronized, so it was not possible to have different settings for each.
These behaviors are not described in the documentation.
It would be understandable if the transition from watch "extension" to watch "app" is to split the app into two separate units.
However, since there is no official documentation explaining this, i cannot determine whether this is the correct specification or not.
Furthermore, since the companion app is required rather than a separate Watch app, having the Health Care permission settings out of sync with the companion app could cause unexpected problems and worsen the user experience.
(It would be difficult and cumbersome for the user to know what settings they have made).
Is there a solution to synchronize this behavior with the companion app like as the Old WatchApp Project?
Do i have to go back to the project configuration (use of watchExtension) before Xcode13?
I have prepared a sample project below that can test the above.
https://github.com/HayakawaAKIRA/SingleTargetWatchOSApp-HealthKit
reference:
https://developer.apple.com/videos/play/wwdc2022/10133/
https://developer.apple.com/documentation/watchkit/wkapplication
https://developer.apple.com/documentation/healthkit/setting_up_healthkit
Post not yet marked as solved
I have an iOS/wOS app that launched last year. Now I want to add complications to it and use the new way of doing complications with WidgetKit. I have everything in place up to the point where I'm supposed to read the data from Health to display it, where it fails with Missing com.apple.developer.healthkit entitlement.
This is the new extension I've added
It's embedded in the WatchKit app NOT in the WatchKit Extension and I've added permission to read health data directly in the info.plist for the extension
I pull the data from the TimelineProvider protocol method
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
let currentDate = Date()
var entries: [WorkoutEntry] = []
ComplicationHealthManager.loadPreviousWorkouts { workout in
let workoutEntry = WorkoutEntry(date: currentDate, workout: workout)
entries.append(workoutEntry)
let timeline = Timeline(entries: entries, policy: .after(currentDate))
completion(timeline)
}
}
with the help of a small manager class
class ComplicationHealthManager: ObservableObject {
static func loadPreviousWorkouts(completion: @escaping (HKWorkout?) -> Void) {
let healthStore: HKHealthStore = HKHealthStore()
let workoutPredicate = HKQuery.predicateForWorkouts(with: .traditionalStrengthTraining)
let compound = NSCompoundPredicate(andPredicateWithSubpredicates:
[workoutPredicate])
let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierEndDate,
ascending: false)
let query = HKSampleQuery(
sampleType: .workoutType(),
predicate: compound,
limit: 0,
sortDescriptors: [sortDescriptor]) { (query, samples, error) in
guard
let samples = samples as? [HKWorkout],
error == nil
else {
completion(nil)
return
}
let calendar = Calendar.current
let todaysSamples = samples.filter{ calendar.isDateInToday($0.endDate) }.last
completion(todaysSamples)
}
healthStore.execute(query)
}
}
The issue is in the closure for the health query where it returns with no workouts but an error stating
Error Domain=com.apple.healthkit Code=4 "Missing com.apple.developer.healthkit entitlement." UserInfo={NSLocalizedDescription=Missing com.apple.developer.healthkit entitlement.}
The problem here is I don't understand where and how to add an entitlement for the complication extension or the WatchKit app, as none of them have the option for health. I have a health entitlements set for the iPhone app and the WatchKit Extension.
Post not yet marked as solved
I'm using the new watchOS 9 HKWorkoutActivity in my interval training app (Intervals Pro) for each interval. It's a great addition since all the intervals now show in the Apple Fitness app, however, if the workout has lots of activities then saving the workout is painfully slow. For example, on my Apple Watch Ultra I saved a workout with 63 activities and it took more than 1 minute. Here's a code snippet:
try await builder.endCollection(at: workoutEndDate)
try await builder.addMetadata(metadata)
try await builder.finishWorkout() // This is SLOW
Is anyone else having the same issue?
To demonstrate the issue you can look at a Test Flight build of Intervals Pro:
https://testflight.apple.com/join/Nn7iSOzY
Tap on the More tab in the iPhone app and then the Apple Watch Settings. On that screen you'll see a switch to either enable or disable workout activities. To demonstrate the issue, edit a timer to continue until manually stopped by changing the Number of Cycles to "Until Stopped". Then start the timer on the watch. Let it run for a period of time to create more than 50 intervals, for example, then stop the timer. Swipe to the leftmost screen on the watch, tap pause, then tap end. At that point you'll see how slow the workout saved.
Next, you can go back to the iPhone app, disable using workout activities and repeat the test. The workout will save quickly in this case.
I've filed a feedback.
Post not yet marked as solved
We have a SwiftUI watch app that has the workout processing background mode. Every time our users raise their wrist the app opens. I understand that this is one of the abilities granted by Apple with the given background mode for active workouts. I wonder if there is a way for us to programmatically turn off this ability, given that this also drains the users battery.
Thanks
Post not yet marked as solved
Hi,I'm a developer of wearable devices.
I am currently making an application that automatically records exercise.
However, Apple Watch seems to have a problem in which data from acceleration sensors and gyro sensors are not recorded in real time when the wrist is turned or the screen is turned off.
Is there a way to keep recording data even if the screen goes off or my wrist goes around? It's like Apple's basic exercise app
Post not yet marked as solved
Hi, I´m new at develping in the Apple and SwiftUI environment. My friends and I got an idea to create a simple Fitness app to track down our own exercises and activities.
For now we got some concept ideas how the design should be.
But for now 4 days I´m watching out for any possible way to create thies small animation. I ´m trying to create this little animation like thy are in the Fitness WatchApp.
If you know hou to create those animation: please write it down.
Thanks for advance
Have tried several times to reset fitness data.
iPhone 12 i os = 16.5 watch, 9.5 series 4
Post not yet marked as solved
I would like to use this https://developer.apple.com/documentation/healthkit/hkhealthstore/1614170-splittotalenergy but I saw that it's deprecated. Is there any replacement?
Thanks!
Post not yet marked as solved
Is there a reason why neither HealthKit data nor the Health App is available on an iPad? And any suggestions how Apple could be convinced to enable that?
Post not yet marked as solved
Is it possible to create a custom HealthKit sample type?
Let's say for example I want to tack how many alcoholic beverages are consumed?
Or how many times a user smokes each day?
There is not a category in HealthKit for these today is it possible for my app to add them as custom data types?
Post not yet marked as solved
Our app has a feature that requires retrieving the user's step count data.
However, since September of last year, some users have reported that they are unable to retrieve their step count. Some of these users are on iOS 15, while others are on iOS 16. Additionally, some users have Apple Watch, while others do not.
Recently, we received an error log stating Unable to invalidate interval: no data source available. However, we are not trying to fetch a large interval of data at once, and the program has a maximum time interval.We are unable to find the problem.
We'd appreciate it if someone could help identify the issue. Thank you.
Post not yet marked as solved
I have two related functions to retrieve the weather and then insert it into a "Live Workout Builder"...
The first function calls the second to get the weather info after which it inserts the metadata into the builder.
public func stopGatheringLocationData() {
logger.info("Stopped gathering location data...")
Task {
let (humidity, temperature) = await getCurrentWeather()
if humidity != nil && temperature != nil {
logger.log("Current humidity \(humidity!), temperature: \(temperature!)")
let metaData = [HKMetadataKeyWeatherHumidity: humidity!, HKMetadataKeyWeatherTemperature: temperature!]
logger.log("Current metadata: \(metaData)")
do {
try await workoutManager.liveBuilder?.addMetadata(metaData)
} catch {
logger.error("FAILED to add weather metadata to workout -> \(error.localizedDescription)")
}
} else {
logger.error("FAILED to retrieve weather data...")
}
}
locationManager.stopUpdatingLocation()
}
private func getCurrentWeather() async -> (humidity: HKQuantity?, temperature: HKQuantity?) {
// Get the weather for the starting location...
let tempUnit = HKUnit.degreeFahrenheit()
let humidityUnit = HKUnit.percent()
guard let startingLocation else {
logger.error("No starting location...")
return (nil, nil)
}
do {
let wx = try await wxService.weather(for: startingLocation)
let humidity = wx.currentWeather.humidity
let temp = wx.currentWeather.temperature.converted(to: .fahrenheit)
let curWx = wx.currentWeather
let wxAttr = try await wxService.attribution.legalAttributionText
await MainActor.run {
currentWx = curWx
wxServiceAttribution = wxAttr
}
return (HKQuantity(unit: humidityUnit, doubleValue: humidity), HKQuantity(unit: tempUnit, doubleValue: temp.value))
} catch {
logger.error("FAILED to retrieve weather data -> \(error.localizedDescription)")
return (nil, nil)
}
}
The two log statements in the first function print out the following information:
[Location/Weather] Current humidity 52 %, temperature: 76.226 degF
[Location/Weather] Current metadata: ["HKWeatherTemperature": 76.226 degF, "HKWeatherHumidity": 52 %]
However, when I look at the workout in the Activity app on my iPhone, the map generated by my app is present but the weather information is missing. The data looks formatted correctly per the limited documentation but for some reason that data is just not showing up.
Any help greatly appreciated...
Post not yet marked as solved
Hello,
I'm having a problem on my watchOS app where even though I have instantiated a WKExtendedRuntimeSession the app stops logging IMU data a few seconds after the watch has gone to sleep.
This happens on my Apple Watch Series 6, but does not happen on the latest Apple Watch Series 8. CPU usage in both cases does not exceed 70%, so I doubt my app is exceeding the limits thus cancelling the WKExtendedRuntimeSession. To back that up, I am not getting the WKExtendedRuntimeSessionInvalidationReason trigger I was suggested to put in place form the documentation.
I have tested a couple of different sample rates, this does not seem to happen with a sample rate as low as 1, but does happen already with a sample rate of 30.
Could it be a watch limitation, or am I forgetting something?
P.S. I have also set the background mode to physical therapy and ticket the workout processing box.
Post not yet marked as solved
I am building an app that requires real time (minute level) body temperature data. I couldn't find the api to do that. Does HealthKit offer this data?
Post not yet marked as solved
I'm trying to make a simple workout app that gets data from the health app (not an app that you use the record the actual workout). I can get data from the health app and manually add workouts but I couldn't find out how to record one with a map. Is there a way for me to either upload a GPX file for the workout, record it on the watch, or some other way to get the workout with a map on the simulator.