> For the complete documentation index, see [llms.txt](https://docs.sentiance.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sentiance.com/getting-started/sdk-integration/2.-including-the-sdk/ios.md).

# iOS

## External Dependencies

The Sentiance SDK has the following external library dependencies. These are automatically included during the build.

* **TensorFlowLiteC**: version <mark style="color:$success;">**`2.17.0`**</mark>. If your app depends on a different version, please reach out to us to address possible incompatibility issues.
* **Protobuf**: version <mark style="color:$success;">**`3.18`**</mark>. A higher version is also acceptable.
* **UnzipKit**: version <mark style="color:$success;">**`1.9`**</mark>. A higher version is also acceptable.

## Steps

{% stepper %}
{% step %}

### Add the Dependency

There are several ways to include the Sentiance SDK in your project. Choose the method that best fits your setup.\
\
The latest SDK version can be found at [Versions & Changelog](/sdk/versions-and-changelog.md).

<details>

<summary>Swift Package Manager (Recommended)</summary>

[Swift Package Manager](https://developer.apple.com/documentation/xcode/swift-packages) is a tool for managing dependencies which simplifies adding 3rd-party frameworks to your projects.

### Steps <a href="#steps" id="steps"></a>

1. In your Xcode project, go to File -> Add Package Dependencies.
2. In the search bar, enter the URL: <https://github.com/sentiance/sentsdk-package>
3. Select **sentsdk-package** from the results.
4. Choose "**Up to Next Minor Version**" as the Dependency Rule. The latest SDK version can be found at [Versions & Changelog](/sdk/versions-and-changelog.md).
5. Select your project from the "**Add to Project**" section, and click **Add Package**. Wait for the product selection dialog to load.
6. A dialog will appear showing the following packages:
   * <mark style="color:$success;">**`ProtocolBuffersObjC`**</mark>
   * <mark style="color:$success;">**`SENTSDK`**</mark>
   * <mark style="color:$success;">**`TensorFlowLiteC`**</mark>
   * <mark style="color:$success;">**`UnzipKit`**</mark>
7. On the same dialog box, use "**Add to Target**" to add all packages to your app.
8. Finally, in your project build settings, add the following to the **Other Linker Flags**:&#x20;
   * <mark style="color:$success;">**`-lz`**</mark>&#x20;
   * <mark style="color:$success;">**`-lc++`**</mark>&#x20;
   * <mark style="color:$success;">**`-all_load`**</mark>

{% hint style="info" %}
If at any point you need to redo the package installation, you can remove the SENTSDK and its packages through your Project > select your target > General > Frameworks, Libraries, and Embedded Content.
{% endhint %}

</details>

<details>

<summary>Cocoapods</summary>

[CocoaPods](https://cocoapods.org/) is an open source dependency manager for iOS projects. **It is scheduled for end of life in December 2026.**

### Steps

1. Make sure you are using CocoaPods **v1.10.0** or above.
2. In your <mark style="color:$success;">**`Podfile`**</mark>, add the Sentiance SDK pod dependency:

```python
## Target Development Version
platform :ios, '15.0'

target 'MyApp' do
  use_frameworks!
  
  ## Pods for your app
  pod 'SENTSDK', '~>x.y.z'  # Replace x.y.z with the latest SDK version.

end
```

3. Run <mark style="color:$success;">**`pod install --repo-update`**</mark> to install the Sentiance SDK pod. The result should look as follows:

```javascript
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing Protobuf (3.29.6)
Installing SENTSDK (6.21.3)
Installing TensorFlowLiteC (2.17.0)
Installing UnzipKit (1.9)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `MyApp.xcworkspace` for this project from now on.
Pod installation complete! There is 1 dependency from the Podfile and 4 total pods installed.
```

4. Open your project using the <mark style="color:$warning;">`xcworkspace`</mark> file and verify that Xcode builds your app without any issues.

{% hint style="danger" %}
If Xcode runs into rsync or sandbox errors, please [follow the steps here](https://app.gitbook.com/o/-LTy4edtsWdQgbEsKB-i/s/YBq0zewxkIeJ41RyTWOa/~/edit/~/changes/59/important-topics/faq/troubleshooting-issues/xcode-sandbox-and-rsync) to enable sandbox code.

<mark style="color:$danger;">`Sandbox: rsync(59862) deny(1) file-write-create`</mark>&#x20;
{% endhint %}

{% hint style="warning" %}
If you see target deployment warning for Protobuf and Unzipkit, you can safely ignore them:

`Protobuf: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 26.2.99.`

`Unzipkit: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 26.2.99.`
{% endhint %}

</details>

<details>

<summary>Carthage</summary>

[Carthage](https://github.com/Carthage/Carthage) is a decentralized, lightweight dependency manager for iOS.

### Steps <a href="#steps" id="steps"></a>

1. Add the following line in your <mark style="color:$success;">**`Cartfile`**</mark>:

```
binary "https://sentiance-u1-sdk-downloads.s3-eu-west-1.amazonaws.com/ios/carthage/SENTSDK.json"
```

2\. Then run the following command in the terminal:

```
carthage update --use-xcframeworks
```

3\. Drag the built **.xcframework** binary from **Carthage/Build/** into *Frameworks, Libraries and Embedded content* section under *General* tab of your application target.

4\. Depending on your Xcode setup, it might be required to add the following libraries: libz.tbd (previously libz.dylib), CoreMotion, SystemConfiguration, CoreLocation, Foundation, CallKit, CoreTelephony, CoreData.

5\. Follow steps 3, 4, and 5 of the manual integration guide.

</details>

<details>

<summary>Manual Integration</summary>

If you want to include the Sentiance SDK without using any dependency management tool, follow the steps below. Note that to keep up with new SDK patches and versions, you will need to update the SDK framework manually.

### Steps <a href="#id-1.-download-the-sdk" id="id-1.-download-the-sdk"></a>

#### **1. Download the SDK** <a href="#id-1.-download-the-sdk" id="id-1.-download-the-sdk"></a>

Download the latest [umbrella Sentiance iOS SDK](/sdk/appendix/ios/v6.x-framework-files.md).

#### 2. Import the Framework <a href="#manual-integration-step-2" id="manual-integration-step-2"></a>

After you've downloaded and unzipped the SDK, import it as a linked library in your Xcode project:

1. Go to the **General** tab of your target settings.
2. Click the **+** button under the **Frameworks, Libraries, and Embedded Content** heading.
3. Click **Add Other** and then **Add Files**.
4. Choose the **Sentiance XCFramework** file and click **Open**.
5. After the item has been added to the list, change the **Embed** option next to the framework to **Do Not Embed**.
6. Depending on your Xcode setup, it might be required to add the following libraries: libz.tbd (previously libz.dylib), CoreMotion, SystemConfiguration, CoreLocation, Foundation, CallKit, CoreTelephony, CoreData.

#### 3. Include the Bundles <a href="#manual-integration-step-3" id="manual-integration-step-3"></a>

Include the SDK and Protobuf bundles in your project:

1. Go to the **Build Phases** tab of your target settings.
2. Expand the **Copy Bundle Resources** row and click the **+** button.
3. Choose the **SENTSDK.bundle** file located inside the **SENTSDK library**.
4. Next, choose the **Protobuf\_Privacy.bundle** file located inside the **Protobuf library**.

#### **4. Import the Dependencies** <a href="#id-4.-import-the-dependencies" id="id-4.-import-the-dependencies"></a>

The SDK XCFramework includes all its necessary dependencies under the **External** directory. For each dependency, do the following:

1. Go to the **General** tab of your target settings.
2. Click the **+** button under the **Frameworks, Libraries, and Embedded Content** heading.
3. Click **Add Other** and then **Add Files**.
4. Go to the **Frameworks** folder inside the Sentiance framework, select the dependency .**xcframework** file and click **Open**.
5. After the item has been added to the list, update the **Embed** option next to the framework as follows:

```
ProtocolBuffers.xcframework - Do Not Embed
UnzipKit.xcframework - Do Not Embed
SENTTensorFlowLiteC.xcframework - Embed & Sign
mpde.xcframework - Embed & Sign
dskoball.xcframework - Embed & Sign
```

#### 5. Update the Build Settings <a href="#id-5.-update-the-build-settings" id="id-5.-update-the-build-settings"></a>

1. Go to the **Build Settings** tab of your target settings.
2. Look for **Other Linker Flags** in the **Linking** section.
3. Add <mark style="color:$success;">**`-lz`**</mark> , <mark style="color:$success;">**`-all_load`**</mark>, and <mark style="color:$success;">**`-lc++`**</mark>

</details>
{% endstep %}

{% step %}

### Configure the Project Capabilities

1. Open your project in **Xcode**
2. In the **Project Navigator** (left sidebar), click the <mark style="color:blue;">**blue project icon**</mark> at the top
3. Under **TARGETS**, select your app target
4. At the top of the editor, open the <mark style="color:$success;">**`Signing & Capabilities`**</mark> tab
5. Click the **“+ Capability”** button near the top-left of the editor
6. In the capability list, select **Background Modes**
7. In **Background Modes**, enable the following capabilities:
   * <mark style="color:$success;">**`Background Fetch`**</mark>
   * <mark style="color:$success;">**`Background Processing`**</mark>
   * <mark style="color:$success;">**`Location Updates`**</mark>

The configuration should appear similar to the example shown below:

<figure><img src="/files/BJMgXwLQQYsDN0yCV1go" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Include the Background Task Identifier

The Sentiance SDK occasionally schedules background work, and as such, requires a background task identifier to be specified in your project's info (Info.plist):

1. At the top of the editor, open the <mark style="color:$success;">**`Info`**</mark> tab
2. Under **Custom iOS Target Properties**, locate <mark style="color:$success;">**`Permitted background task scheduler identifiers`**</mark>
3. If the key does not exist, **click + and add it as an Array**
4. Add the following background task identifier as a String item in the array: <mark style="color:$success;">**`com.sentiance.backgroundtask.task_processing`**</mark>

The configuration should appear as follows:

<figure><img src="/files/o4VTwon13rw8Y3xyLJrQ" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Configure Privacy Permission Descriptions

There are few permissions that required to support Sentiance's core functionality. Request these permissions by **clearly explaining to users why they are needed and how the corresponding data will be used**.

1. Open your project's <mark style="color:$success;">**`Info`**</mark> tab.
2. Add the required privacy keys if they don’t already exist.
3. For each key, set a clear, user-friendly description explaining why the permission is needed and how it benefits the user:
   * <mark style="color:$success;">**`Privacy - Location Always Usage Description`**</mark>
   * <mark style="color:$success;">**`Privacy - Location When In Use Usage Description`**</mark>
   * <mark style="color:$success;">**`Privacy - Location Always and When In Use Usage Description`**</mark>
   * <mark style="color:$success;">**`Privacy - Motion Usage Description`**</mark>&#x20;

{% hint style="info" %}
In the **Info.plist** file, these privacy settings will show up as:

* NSLocationAlwaysUsageDescription
* NSLocationWhenInUseUsageDescription
* NSLocationAlwaysAndWhenInUseUsageDescription
* NSMotionUsageDescription
  {% endhint %}

The configuration should appear similar to the following example:

<figure><img src="/files/zb9Revql9rB1R1sC24zx" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Next: Initialize the SDK

After having included the sentence SDK, proceed to initializing the SDK.
{% endstep %}
{% endstepper %}
