iOS

Learn how to install the Sahha SDK in your iOS project

Installation

Follow these steps to install the Sahha SDK in your iOS project.


Option A) Swift Package Manager

Add the Sahha swift package to your project's Package Dependencies.

https://github.com/sahha-ai/sahha-swift

Option B) CocoaPods

📘

Install CocoaPods

Visit cocoapods.org to learn how to install CocoaPods.

Step 1) Add the Sahha pod to your project's Podfile.

 pod 'Sahha'

Step 2) Run pod install from the Terminal app in your project root folder.

$ pod install

Import Module

After you have installed the Sahha SDK, import the Sahha module into any files inside your project that use the SDK.

import Sahha

Project Settings

You will need to edit your project settings to enable the Sahha SDK.


Usage Descriptions

👍

Add usage descriptions to your Xcode project

You will need to write a message explaining to the user why they should approve these permissions.

  • Add NSMotionUsageDescription
  • Add NSHealthShareUsageDescription
  • Add NSHealthUpdateUsageDescription

HealthKit Entitlement

👍

Add HealthKit entitlement to your Xcode project

  • Select your App Target in the Project panel
  • Select Signing & Capabilities
  • Tap the + button
  • Select HealthKit from the list
  • Set Background Delivery to true

Background Modes Entitlement

👍

Add Background Modes entitlement to your Xcode project

  • Select your App Target in the Project panel
  • Select Signing & Capabilities
  • Tap the + button
  • Select Background Modes from the list
  • Set Background Fetch to true
  • Set Background Processing to true

Info.plist

You can also edit the Info.plist file directly.

<plist version="1.0">
<dict>
  <key>NSMotionUsageDescription</key>
  <string>This app would like access to your motion activity for analysis.</string>
<key>NSHealthShareUsageDescription</key>
  <string>This app would like access to your health activity for analysis.</string>
<key>NSHealthUpdateUsageDescription</key>
  <string>This app would like access to your health activity for analysis.</string>
<key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>processing</string>
    </array>
</dict>
</plist>

App.entitlements

You can also edit the App.entitlements file directly.

<plist version="1.0">
<dict>
 <key>com.apple.developer.healthkit</key>
  <true/>
 <key>com.apple.developer.healthkit.access</key>
  <array/>
 <key>com.apple.developer.healthkit.background-delivery</key>
  <true/>
</dict>
</plist>

What's next?