Installation
To integrate Stream Chat in your app, you can use one of the following dependency managers:
We also provide pre-built XCFramework support, read more here.
Swift Package Manager
Open your .xcodeproj
, select the option "Add Package..." in the File menu, and paste the URL for the library you want to integrate:
- For the LLC (StreamChat) use:
https://github.com/getstream/stream-chat-swift
- For the UIKit components (StreamChatUI, which depends on StreamChat) use:
https://github.com/getstream/stream-chat-swift
- For the SwiftUI components (StreamChatSwiftUI, which depends on StreamChat) use:
https://github.com/getstream/stream-chat-swiftui
➤ Do you want to use XCFrameworks? (Click to read more)
Our XCFrameworks are built with Swift 5.7. In order to use them you need Xcode 14 or above
You can learn more about our Module Stable XCFrameworks here
- For the LLC (StreamChat) use:
https://github.com/getstream/stream-chat-swift-spm
- For the UIKit components (StreamChatUI, which depends on StreamChat) use:
https://github.com/getstream/stream-chat-swift-spm
After introducing the desired URL, Xcode will look for the Packages available in the repository and automatically select the latest version tagged. Press next and Xcode will download the dependency.
Based on the repository you select you can find 3 different targets: StreamChat, StreamChatUI and StreamChatSwiftUI.
- If you want to use the UIKit components, select StreamChatUI.
- If you want to use the SwiftUI components, select StreamChatSwiftUI.
- If you don't need any UI components, select StreamChat.
After you press finish, it's done.
Because StreamChat SDKs have to be distributed with its resources, the minimal Swift version requirement for this installation method is 5.3. If you need to support older Swift version, please install it using CocoaPods.
More information about Swift Package Manager can be found here
CocoaPods
In your project's Podfile
, add one of these options
- For the LLC (StreamChat) use:
pod 'StreamChat', '~> 4.0.0'
- For the UIKit components (StreamChatUI, which depends on StreamChat) use:
pod 'StreamChatUI', '~> 4.0.0'
- For the SwiftUI components (StreamChatSwiftUI, which depends on StreamChat) use:
pod 'StreamChatSwiftUI', '~> 4.0.0'
➤ Do you want to use XCFrameworks? (Click to read more)
Our XCFrameworks are built with Swift 5.7. In order to use them you need Xcode 14 or above
You can learn more about our Module Stable XCFrameworks here
- For the LLC (StreamChat) use:
pod 'StreamChat-XCFramework', '~> 4.6.0'
- For the UIKit components (StreamChatUI, which depends on StreamChat) use:
pod 'StreamChatUI-XCFramework', '~> 4.6.0'
Example: If you want to use the UIKit components, it should look similar the snippet below.
target 'MyProject' do
use_frameworks!
# Pods for MyProject
pod 'StreamChatUI', '~> 4.0.0'
end
StreamChatUI and StreamChatSwiftUI pod will automatically include the StreamChat dependency. If you want just the StreamChat dependency, without the UI components, use StreamChat as shown above.
Now that we’ve modified our Podfile, let’s go ahead and install the project dependencies via the terminal with one simple command:
pod install --repo-update
The above command will generate the MyProject.xcworkspace file automatically.
With our workspace now containing our Pods project with dependencies, as well as our original project, let’s go ahead and move over to Xcode to complete the process.
More information about CocoaPods can be found here.
Carthage
If you are using Swift 5.7 / Xcode 14 or above, the recommended method for Carthage is to use pre-built XCFrameworks.
Our SwiftUI components library is not yet available using Carthage, please use Swift Package Manager or CocoaPods.
➤ Using pre-built XCFrameworks
Our XCFrameworks are built with Swift 5.7. In order to use them you need Xcode 14 or above
You can learn more about our Module Stable XCFrameworks here
- For the LLC (StreamChat) use:
binary "https://raw.githubusercontent.com/GetStream/stream-chat-swift/main/StreamChatArtifacts.json" ~> 4.6
- For the UIKit components (StreamChatUI, which depends on StreamChat) use:
binary "https://raw.githubusercontent.com/GetStream/stream-chat-swift/main/StreamChatArtifacts.json" ~> 4.6
Now that we’ve modified our Cartfile, let’s go ahead and install the project dependencies via the terminal with one simple command:
carthage update --use-xcframeworks
The previous command will download pre-built XCFrameworks. You now need to add those to your project. Keep reading.
➤ Building from source (OSS)
In your project's Cartfile
, add one of these options
- For the LLC (StreamChat) use:
github "getstream/stream-chat-swift" ~> 4.6.0
- For the UIKit components (StreamChatUI, which depends on StreamChat) use:
github "getstream/stream-chat-swift" ~> 4.6.0
Now that we’ve modified our Cartfile, let’s go ahead and install the project dependencies via the terminal with one simple command:
carthage update --use-xcframeworks --no-use-binaries --platform iOS
The previous command will create pre-built XCFrameworks built from our source code (This might take a while ⏱). You now need to add those to your project. Keep reading.
Open the Carthage/Build
folder that has been created in the root of your project, and drag and drop the frameworks you want to use. Those should be added to the "Frameworks, Libraries, and Embedded Content" section under General settings:
Make sure you select Embed & Sign under "Embed" options if you are adding Stream libraries to an app target. If not, use Do Not Embed
More information about Carthage can be found here.
XCFrameworks
In an effort to have Module Stability, we have started distributing pre-built XCFrameworks starting 4.6.0
Our XCFrameworks are built with Swift 5.7. In order to use them you need Xcode 14 or above.
An XCFramework is a package that contains binaries for multiple architectures/platforms, but only the particular slice of that package required for your architecture/platform will be used.
Benefits of XCFrameworks:
- Conveniently import a single package
- Supports all platforms and architectures (We support iOS in StreamChatUI and iOS/macOS in StreamChat)
- No more fat binaries. No more architectures stripping
Does this mean that from now on, I will need to import Stream manually?
No, all the known dependency managers support this format, and this most likely happens without you even noticing.
Module Stability:
While ABI Stability was allowing us to have code written with different Swift versions in the same runtime, Module Stability enables us to use a library built in a particular version of the compiler running in a different version of the compiler (Think of a framework that is built using Swift X to work on an app built with Swift X+1).
Add Usage Descriptions to Info.plist
Add the NSPhotoLibraryUsageDescription key in your Info.plist with a description of use. Add the NSPhotoLibraryAddUsageDescription key in your Info.plist with a description of use. Add the NSCameraUsageDescription key in your Info.plist with a description of use.