watchOS 9 WidgetKit complications missing com.apple.developer.healthkit entitlement

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.

I found the problem to be that I had the old implementation of watchkit apps, with both a Watch app and a Watch extension. That was the problem. I went and used the migration from Xcode 14 to merge the Watch App and Extension into a new watch app and everything works now.

I've found that I am unable to add the HealthKit entitlement to my Watch app Widget Extension, but I can add it to my iPhone app Widget Extension... I also don't seem to need it in my Watch app Widget Extension. Is there any guidance or recommendations on this?

Thanks

watchOS 9 WidgetKit complications missing com.apple.developer.healthkit entitlement
 
 
Q