Over the next few weeks I will be revisiting some of the older tutorials on this site from several years ago. Today I updated How to Use HealthKit HKAnchoredObjectQuery to be compatible with iOS 18. Almost all of it was good, although I feel it needs another look at, this time using SwiftUI to build a view for it so you can visually see the data and the anchor.

The screenshot you see shows what you will be building with your own data from HealthKit.
Begin by creating a new Xcode project selecting SwiftUI. When loaded, there are a few steps to take to get the app ready to access HealthKit data. One is a permission adjustment in info.plist so that the user can be prompted to give permission. The second is the HealthKit entitlement. Let’s look at these now.