Adding the Chat SDK
Adding the Chat SDK
You can add the Chat SDK to your project using one of the following methods:
Adding the SDK with SPM
The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
To add the Chat SDK to your project as a dependency:
-
Follow the Apple documentation on how to add the package to your project.
-
Paste the Chat SDK package URL, https://github.com/zendesk/chat_sdk_ios, into the Choose repository package search bar.
-
Use version-based Package Requirements, and set the value to the latest version of the SDK.
Adding the SDK with CocoaPods
CocoaPods is a dependency manager that lets you add third-party frameworks and libraries to projects. For installation instructions, see Install CocoaPods.
If not already done, create a Podfile for your project as follows:
-
In Terminal, navigate to the top-level folder of your project (the one with the xcodeproj file).
-
Create a Podfile using the
pod init
command. -
Add the
ZendeskChatSDK
pod to your Podfile.target 'My Sample App' do
pod 'ZendeskChatSDK'
end
If you decide to build your own UI, then you will need to add the ZendeskChatProvidersSDK pod instead.
target 'My Sample App' do
pod 'ZendeskChatProvidersSDK'
end
Note: If you're using Objective-C, you'll need to include
use_frameworks!
. -
Run the
pod install
command.
Because your project now contains a dependency managed by CocoaPods, you must open the project in Xcode by double-clicking the .xcworkspace file, not .xcodeproj.
For more information, see Using CocoaPods on cocoapods.org.
Adding the SDK with Carthage
Carthage is a third party dependency manager for iOS applications. For installation and usage instructions, see Installing Carthage in the Carthage readme on Github.
-
Add the following lines to your Cartfile to import the necessary frameworks for working with the UI we provide:
github "zendesk/chat_sdk_ios" ~> 5.0.4
Note: If you decide to build your own UI, you will only need to add the ChatProvidersSDK to your Cartfile.
github "zendesk/chat_providers_sdk_ios" ~> 5.0.4
-
Run the
carthage update --use-xcframeworks
command. -
On your target's General tab, drag each of the following frameworks from the Carthage/Build/iOS folder to the Frameworks, Libraries and Embedded Content section and embed the frameworks by selecting Embed & Sign option.
Note: Your app's build targets must point the
FRAMEWORK_SEARCH_PATHS
setting to theCarthage/Build/iOS
folder.
Adding the SDK manually
-
Download the following ZIP files:
# Chat provider layer framework
https://github.com/zendesk/chat_providers_sdk_ios/releases/download/5.0.4/ChatProvidersSDK.xcframework.zip
# Chat UI layer framework
https://github.com/zendesk/chat_sdk_ios/releases/download/5.0.4/ChatSDK.xcframework.zip
# Shared Zendesk UI frameworks
https://github.com/zendesk/messaging_sdk_ios/releases/download/6.0.2/MessagingSDK.xcframework.zip
https://github.com/zendesk/messagingapi_sdk_ios/releases/download/6.0.1/MessagingAPI.xcframework.zip
https://github.com/zendesk/commonui_sdk_ios/releases/download/9.0.2/CommonUISDK.xcframework.zip
https://github.com/zendesk/sdkconfigurations_sdk_ios/releases/download/4.0.0/SDKConfigurations.xcframework.zip
Note: If you decide to build your own UI, you will only need to add the ChatProvidersSDK framework.
https://github.com/zendesk/chat_providers_sdk_ios/releases/download/5.0.4/ChatProvidersSDK.xcframework.zip
You can also batch download the ZIP files by copying the above list, pasting it into a text file and running the following command:
wget -i _the_name_of_the_file_you_created_
Note: You can install the
wget
tool with Homebrew usingbrew install wget
. -
In Xcode, select your project in Project navigator:
-
In Finder, navigate to where you extracted the SDKs.
-
Ensure a Frameworks directory exists in the top level of your project directory. Create this directory if it does not exist.
-
Copy the following items into the Frameworks folder in your project:
- ChatSDK.xcframework
- ChatProvidersSDK.xcframework
- CommonUISDK.xcframework
- SDKConfigurations.xcframework
- MessagingSDK.xcframework
- MessagingAPI.xcframework
-
Drag the frameworks into the Frameworks, Libraries and Embedded Content section of your project and embed the frameworks by selecting Embed & Sign option.
-
In Build Settings set the CLANG_ENABLE_MODULES field to YES.