---
title: 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

{% callout title="Your iOS project must support:" %}

- iOS 15 or above
- Swift 5 or above

{% /callout %}

---

## 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.

{% callout title="Add the HealthKit entitlement" %}

- Select your app target in the Project navigator
- Select `Signing & Capabilities`
- Click the `+` button
- Select `HealthKit` from the list
- Double-click the capability to add it to your project

{% /callout %}

Select the project in the navigator, choose your target, and open the Signing & Capabilities tab.

![Xcode project navigator showing Signing & Capabilities tab](/images/connect/sdk/hk_capability_1.png)

Click the Library button (+) to open the Capabilities library.

![Xcode Capabilities library dialog](/images/connect/sdk/hk_capability_2.png)

Select `HealthKit` from the list.

![Selecting HealthKit from the Capabilities library](/images/connect/sdk/hk_capability_3.png)

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.

{% callout title="Enable Background Delivery" %}

- In Signing & Capabilities, find the HealthKit capability you just added
- Check the **Background Delivery** option

{% /callout %}

![HealthKit capability with Background Delivery checkbox enabled](/images/connect/sdk/hk_background_delivery.png)

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.

{% callout title="Add Background Modes" %}

- In Signing & Capabilities, click the `+` button
- Select `Background Modes` from the list
- Double-click the capability to add it
- Check **Background Fetch** and **Background Processing**

{% /callout %}

![Selecting Background Modes from the Capabilities library](/images/connect/sdk/hk_background_modes.png)

![Background Modes options with Background Fetch and Background Processing checked](/images/connect/sdk/hk_background_modes_options.png)

---

### 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.

{% callout title="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 Description` with a value like `This app needs your health info to deliver health scores.`
- Add `Privacy - Motion Usage Description` with a value like `This app needs access to motion to capture health information and trigger background processing.`

{% /callout %}

![Info tab showing Privacy usage description keys](/images/connect/sdk/hk_share_usage.png)

---

## 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)

```text
https://github.com/sahha-ai/sahha-ios
```

### Option B: CocoaPods

{% callout title="Install CocoaPods" %}

Visit [CocoaPods](https://cocoapods.org/) to learn how to install CocoaPods if you don't have it yet.

{% /callout %}

Add the Sahha pod to your project's `Podfile`:

```ruby title="Podfile"
pod 'Sahha'
```

Then run `pod install` from your project root:

```shell-session title="Terminal"
$ pod install
```

---

## Import the Module

Import Sahha in any file where you use the SDK:

```swift title="MyApp.swift"
import Sahha
```

---

## Next Steps

Continue to [Step 2) Configure Settings](/docs/connect/sdk/configuration) to set your environment and notification preferences.
