generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Documentation Catalog and bump to Spezi 1.0 (#15)
# Add Documentation Catalog and bump to Spezi 1.0 ## ♻️ Current situation & Problem This PR improves documentation by adding a DocC documentation catalog. Further, we upgrade the package to the latest Spezi 1.0 release. ## ⚙️ Release Notes * Add proper documentation landing page * Upgrade to Spezi 1.0 releases ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
- Loading branch information
Showing
4 changed files
with
171 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
Sources/SpeziHealthKit/SpeziHealthKit.docc/SpeziHealthKit.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# ``SpeziHealthKit`` | ||
|
||
<!-- | ||
# | ||
# This source file is part of the Stanford Spezi open source project | ||
# | ||
# SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
--> | ||
|
||
Simplified access to HealthKit samples ranging from single, anchored, and background queries. | ||
|
||
## Overview | ||
|
||
The Spezi HealthKit module simplifies access to HealthKit samples ranging from single, anchored, and background queries. | ||
|
||
### Setup | ||
|
||
You need to add the Spezi HealthKit Swift package to | ||
[your app in Xcode](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app) or | ||
[Swift package](https://developer.apple.com/documentation/xcode/creating-a-standalone-swift-package-with-xcode#Add-a-dependency-on-another-Swift-package). | ||
|
||
> Important: If your application is not yet configured to use Spezi, follow the | ||
[Spezi setup article](https://swiftpackageindex.com/stanfordspezi/spezi/documentation/spezi/initial-setup) and set up the core Spezi infrastructure. | ||
|
||
### Example | ||
|
||
Before you configure the ``HealthKit`` module, make sure your `Standard` in your Spezi Application conforms to the ``HealthKitConstraint`` protocol to receive HealthKit data. | ||
```swift | ||
actor ExampleStandard: Standard, HealthKitConstraint { | ||
func add(sample: HKSample) async { | ||
// ... | ||
} | ||
|
||
func remove(sample: HKDeletedObject) { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
|
||
Then, you can configure the ``HealthKit`` module in the configuration section of your `SpeziAppDelegate`. | ||
Provide ``HealthKitDataSourceDescription`` to define the data collection. | ||
You can, e.g., use ``CollectSample`` to collect a wide variety of `HKSampleTypes`: | ||
```swift | ||
class ExampleAppDelegate: SpeziAppDelegate { | ||
override var configuration: Configuration { | ||
Configuration(standard: ExampleStandard()) { | ||
if HKHealthStore.isHealthDataAvailable() { | ||
HealthKit { | ||
CollectSample( | ||
HKQuantityType.electrocardiogramType(), | ||
deliverySetting: .background(.manual) | ||
) | ||
CollectSample( | ||
HKQuantityType(.stepCount), | ||
deliverySetting: .background(.afterAuthorizationAndApplicationWillLaunch) | ||
) | ||
CollectSample( | ||
HKQuantityType(.pushCount), | ||
deliverySetting: .anchorQuery(.manual) | ||
) | ||
CollectSample( | ||
HKQuantityType(.activeEnergyBurned), | ||
deliverySetting: .anchorQuery(.afterAuthorizationAndApplicationWillLaunch) | ||
) | ||
CollectSample( | ||
HKQuantityType(.restingHeartRate), | ||
deliverySetting: .manual() | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Topics | ||
|
||
### Module | ||
|
||
- ``HealthKit`` | ||
- ``HealthKitConstraint`` | ||
|
||
### Data Sources | ||
|
||
- ``HealthKitDataSourceDescription`` | ||
- ``HealthKitDataSourceDescriptionBuilder`` | ||
- ``HealthKitDataSource`` | ||
|
||
### Collecting Samples | ||
|
||
- ``CollectSample`` | ||
- ``CollectSamples`` | ||
- ``HealthKitDeliverySetting`` | ||
- ``HealthKitDeliveryStartSetting`` | ||
|