<!--
{
  "availability" : [
    "iOS: 15.4.0 -",
    "iPadOS: 15.4.0 -",
    "macCatalyst: 15.4.0 -",
    "macOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 8.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKSourceQueryDescriptor",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "s:9HealthKit23HKSourceQueryDescriptorV"
  },
  "title" : "HKSourceQueryDescriptor"
}
-->

# HKSourceQueryDescriptor

A query interface that uses Swift concurrency to read the apps and devices that produced the matching samples.

```
struct HKSourceQueryDescriptor<Sample> where Sample : HKSample
```

## Overview

Use [`HKSourceQueryDescriptor`](/documentation/HealthKit/HKSourceQueryDescriptor) to run a general query that returns a snapshot of all the apps and devices that have saved matching data to the HealthKit store.

```swift
// Create the source descriptor.
let sourceDescriptor = HKSourceQueryDescriptor(predicate: .workout())

// Read the source data from the HealthKit store.
let sources = try await sourceDescriptor.result(for: store)

for source in sources {
    // Process the sources here.
    print(source)
}
```

When you call the descriptor’s [`result(for:)`](/documentation/HealthKit/HKSourceQueryDescriptor/result(for:)) method, it creates and executes an [`HKSourceQuery`](/documentation/HealthKit/HKSourceQuery) in the background, passing the results as an array of [`HKSource`](/documentation/HealthKit/HKSource) instances.

## Topics

### Creating Source Query Descriptors

[`init(predicate: HKSamplePredicate<Sample>)`](/documentation/HealthKit/HKSourceQueryDescriptor/init(predicate:))

Creates a source query descriptor.

### Running Queries

[`func result(for: HKHealthStore) async throws -> [HKSource]`](/documentation/HealthKit/HKSourceQueryDescriptor/result(for:))

Runs a one-shot query that asynchronously returns a snapshot of all the sources that saved matching data.

### Accessing Query Properties

[`var predicate: HKSamplePredicate<Sample>`](/documentation/HealthKit/HKSourceQueryDescriptor/predicate)

A predicate that limits the data used by the query.

### Default Implementations

[HKAsyncQuery Implementations](/documentation/HealthKit/HKSourceQueryDescriptor/HKAsyncQuery-Implementations)

## Relationships

### Conforms To

[`HKAsyncQuery`](/documentation/HealthKit/HKAsyncQuery)

[`Escapable`](/documentation/Swift/Escapable)

[`Copyable`](/documentation/Swift/Copyable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)