Install Sahha SDK for iOS
Set up your Xcode project and add the Sahha SDK for iOS.
On iOS, the Sahha SDK reads health and fitness data from Apple Health via Apple's HealthKit framework. This guide walks you through preparing your Xcode project, installing the library, and confirming the import works.
Prerequisites
Your iOS project must support:
- iOS 15 or above
- Swift 5 or above
Set Up Xcode Project
Complete these steps in Xcode before installing the library. They enable your app to read data from Apple Health and continue collecting in the background.
1. Enable HealthKit
Add the HealthKit capability so your app can connect to Apple Health.
Add the HealthKit entitlement
- Select your app target in the Project navigator
- Select
Signing & Capabilities - Click the
+button - Select
HealthKitfrom the list - Double-click the capability to add it to your project
Select the project in the navigator, choose your target, and open the Signing & Capabilities tab.
Click the Library button (+) to open the Capabilities library.
Select HealthKit from the list.
After you add the capability, Xcode links the HealthKit framework to your target and updates the entitlements file. If Xcode manages signing automatically, it also enables HealthKit for your App ID.
2. Enable Background Delivery
Background delivery allows the SDK to receive new health data from Apple Health even when your app is not in the foreground. Without this, data collection stops when the user leaves your app.
Enable Background Delivery
- In Signing & Capabilities, find the HealthKit capability you just added
- Check the Background Delivery option
Xcode adds the com.apple.developer.healthkit.background-delivery entitlement to the target's entitlements file.
3. Enable Background Processing
Background modes allow the SDK to process and upload collected data while the app is in the background.
Add Background Modes
- In Signing & Capabilities, click the
+button - Select
Background Modesfrom the list - Double-click the capability to add it
- Check Background Fetch and Background Processing
4. Add Usage Descriptions
Apple requires your app to include short descriptions that explain why it needs access to health and motion data. These appear in the system permission dialogs and are required for App Store submission.
Add usage descriptions in your target's Info tab
- Select your app target in the Project navigator
- Select
Info - Click the
+button to add a new key - Add
Privacy - Health Share Usage Descriptionwith a value likeThis app needs your health info to deliver health scores. - Add
Privacy - Motion Usage Descriptionwith a value likeThis app needs access to motion to capture health information and trigger background processing.
Install the Library
Choose one of the two options below to install the Sahha library in your Xcode project.
Option A: Swift Package Manager
In Xcode, go to File → Add Package Dependencies . Paste the repository URL below into the search field and follow the prompts to add the package.
View Sahha Swift SDK on GitHub
https://github.com/sahha-ai/sahha-ios https://github.com/sahha-ai/sahha-ios
Option B: CocoaPods
Install CocoaPods
Visit CocoaPods to learn how to install CocoaPods if you don't have it yet.
Add the Sahha pod to your project's Podfile:
pod 'Sahha' pod 'Sahha'
Then run pod install from your project root:
$ pod install $ pod install
Import the Module
Import Sahha in any file where you use the SDK:
import Sahha import Sahha
Next Steps
Continue to Step 2) Configure Settings to set your environment and notification preferences.
- Previous
- 1) Install SDK
- Next
- Android