<!--
{
  "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/HKActivitySummaryQueryDescriptor",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "s:9HealthKit32HKActivitySummaryQueryDescriptorV"
  },
  "title" : "HKActivitySummaryQueryDescriptor"
}
-->

# HKActivitySummaryQueryDescriptor

A query interface that reads activity summaries using Swift concurrency.

```
struct HKActivitySummaryQueryDescriptor
```

## Overview

Use [`HKActivitySummaryQueryDescriptor`](/documentation/HealthKit/HKActivitySummaryQueryDescriptor) to run a query that reads activity summary objects from the HealthKit store. To get a snapshot of activity summaries currently in the store, create a descriptor and call its [`result(for:)`](/documentation/HealthKit/HKActivitySummaryQueryDescriptor/result(for:)) method.

```swift
// Get the start and end date components.
let calendar = Calendar(identifier: .gregorian)

var startComponents = calendar.dateComponents([.day, .month, .year], from: Date())
startComponents.hour = 0
startComponents.minute = 0
startComponents.second = 0

var endComponents = startComponents
endComponents.day = 1 + (endComponents.day ?? 0)


// Create a predicate for the query.
let today = HKQuery.predicate(forActivitySummariesBetweenStart: startComponents, end: endComponents)

// Create the descriptor.
let activeSummaryDescriptor = HKActivitySummaryQueryDescriptor(predicate:today)

// Run the query.
let results = try await activeSummaryDescriptor.result(for: store)
```

To set up a long-running query that returns both matching values currently in the HealthKit store, and any updates that arrive while the query is running, call the [`results(for:)`](/documentation/HealthKit/HKAsyncSequenceQuery/results(for:)) method instead.

```swift
// Run a long-running query and monitor for updates.
let updateQueue = activeSummaryDescriptor.results(for: store)

// Wait for the initial results and updates.
updateTask = Task {
    for try await results in updateQueue {
        // Process results here.
    }
}
```

## Topics

### Creating query descriptors

[`init(predicate: NSPredicate?)`](/documentation/HealthKit/HKActivitySummaryQueryDescriptor/init(predicate:))

Instantiates an activity summary query descriptor.

### Running queries

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

Runs a one-shot query and asynchronously returns a snapshot of the current matching results.

[`func results(for: HKHealthStore) -> HKActivitySummaryQueryDescriptor.Results`](/documentation/HealthKit/HKActivitySummaryQueryDescriptor/results(for:))

Initiates a long-running query that returns its results using an asynchronous sequence.

[`struct Results`](/documentation/HealthKit/HKActivitySummaryQueryDescriptor/Results)

An asynchronous sequence that emits updates from an activity summary query.

### Accessing query properties

[`var predicate: NSPredicate?`](/documentation/HealthKit/HKActivitySummaryQueryDescriptor/predicate)

A predicate that limits the results that the query returned.

### Default Implementations

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

[HKAsyncSequenceQuery Implementations](/documentation/HealthKit/HKActivitySummaryQueryDescriptor/HKAsyncSequenceQuery-Implementations)

## Relationships

### Conforms To

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

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

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

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

---

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)