|
| 1 | +--- |
| 2 | +title: Integration |
| 3 | +--- |
| 4 | + |
| 5 | +# Integration |
| 6 | + |
| 7 | +To integrate Stream Chat in your app, you can use one of the following dependency managers: |
| 8 | + |
| 9 | +- [**Swift Package Manager**](#swift-package-manager) |
| 10 | +- [**CocoaPods**](#cocoapods) |
| 11 | +- [**Carthage**](#carthage) |
| 12 | + |
| 13 | +We also provide pre-built XCFramework support, read more [here](#xcframeworks). |
| 14 | + |
| 15 | +### Swift Package Manager |
| 16 | + |
| 17 | +Open your `.xcodeproj`, select the option "Add Package..." in the File menu, and paste the URL for the library you want to integrate: |
| 18 | + |
| 19 | +- For the LLC (**StreamChat**) use: |
| 20 | + - `https://github.com/getstream/stream-chat-swift` |
| 21 | +- For the UIKit components (**StreamChatUI**, which depends on **StreamChat**) use: |
| 22 | + - `https://github.com/getstream/stream-chat-swift` |
| 23 | +- For the SwiftUI components (**StreamChatSwiftUI**, which depends on **StreamChat**) use: |
| 24 | + - `https://github.com/getstream/stream-chat-swiftui` |
| 25 | + |
| 26 | +<details><summary>➤ Do you want to use <b>XCFrameworks</b>? (Click to read more)</summary> |
| 27 | +<p> |
| 28 | + |
| 29 | +:::caution |
| 30 | +Our XCFrameworks are built with **Swift 5.5**. In order to use them you need **Xcode 13** or above |
| 31 | +::: |
| 32 | + |
| 33 | +You can learn more about [our Module Stable XCFrameworks here](#xcframeworks) |
| 34 | + |
| 35 | +- For the LLC (**StreamChat**) use: |
| 36 | + - `https://github.com/getstream/stream-chat-swift-spm` |
| 37 | +- For the UIKit components (**StreamChatUI**, which depends on **StreamChat**) use: |
| 38 | + - `https://github.com/getstream/stream-chat-swift-spm` |
| 39 | + |
| 40 | +</p> |
| 41 | +</details> |
| 42 | + |
| 43 | + |
| 44 | +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. |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +Based on the repository you select you can find 3 different targets: StreamChat, StreamChatUI and StreamChatSwiftUI. |
| 49 | + |
| 50 | +- If you want to use the UIKit components, select **StreamChatUI**. |
| 51 | +- If you want to use the SwiftUI components, select **StreamChatSwiftUI**. |
| 52 | +- If you don't need any UI components, select **StreamChat**. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +After you press finish, it's done! |
| 57 | + |
| 58 | +:::caution |
| 59 | +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. |
| 60 | +::: |
| 61 | + |
| 62 | +_More information about Swift Package Manager [can be found here](https://www.swift.org/package-manager/)_ |
| 63 | + |
| 64 | +### CocoaPods |
| 65 | + |
| 66 | +In your project's `Podfile`, add one of these options |
| 67 | + |
| 68 | +- For the LLC (**StreamChat**) use: |
| 69 | + - `pod 'StreamChat', '~> 4.0.0'` |
| 70 | +- For the UIKit components (**StreamChatUI**, which depends on **StreamChat**) use: |
| 71 | + - `pod 'StreamChatUI', '~> 4.0.0'` |
| 72 | +- For the SwiftUI components (**StreamChatSwiftUI**, which depends on **StreamChat**) use: |
| 73 | + - `pod 'StreamChatSwiftUI', '~> 4.0.0'` |
| 74 | + |
| 75 | +<details><summary>➤ Do you want to use <b>XCFrameworks</b>? (Click to read more)</summary> |
| 76 | +<p> |
| 77 | + |
| 78 | +:::caution |
| 79 | +Our XCFrameworks are built with **Swift 5.5**. In order to use them you need **Xcode 13** or above |
| 80 | +::: |
| 81 | + |
| 82 | +You can learn more about [our Module Stable XCFrameworks here](#xcframeworks) |
| 83 | + |
| 84 | +- For the LLC (**StreamChat**) use: |
| 85 | + - `pod 'StreamChat-XCFramework', '~> 4.6.0'` |
| 86 | +- For the UIKit components (**StreamChatUI**, which depends on **StreamChat**) use: |
| 87 | + - `pod 'StreamChatUI-XCFramework', '~> 4.6.0'` |
| 88 | + |
| 89 | +</p> |
| 90 | +</details> |
| 91 | + |
| 92 | +Example: If you want to use the UIKit components, it should look similar the snippet below. |
| 93 | + |
| 94 | +```ruby |
| 95 | +target 'MyProject' do |
| 96 | + use_frameworks! |
| 97 | + |
| 98 | + # Pods for MyProject |
| 99 | + pod 'StreamChatUI', '~> 4.0.0' |
| 100 | +end |
| 101 | +``` |
| 102 | + |
| 103 | +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. |
| 104 | + |
| 105 | +Now that we’ve modified our Podfile, let’s go ahead and install the project dependencies via the terminal with one simple command: |
| 106 | + |
| 107 | +```bash |
| 108 | +pod install --repo-update |
| 109 | +``` |
| 110 | + |
| 111 | +The above command will generate the **MyProject.xcworkspace** file automatically. |
| 112 | + |
| 113 | +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. |
| 114 | + |
| 115 | +_More information about CocoaPods [can be found here](https://cocoapods.org/)._ |
| 116 | + |
| 117 | +### Carthage |
| 118 | + |
| 119 | +In your project's `Cartfile`, add one of these options |
| 120 | + |
| 121 | +- For the LLC (**StreamChat**) use: |
| 122 | + - `github "getstream/stream-chat-swift" ~> 4.6.0` |
| 123 | +- For the UIKit components (**StreamChatUI**, which depends on **StreamChat**) use: |
| 124 | + - `github "getstream/stream-chat-swift" ~> 4.6.0` |
| 125 | + |
| 126 | +:::note |
| 127 | +Our SwiftUI components library is not yet available using Carthage, please use Swift Package Manager or CocoaPods. |
| 128 | +::: |
| 129 | + |
| 130 | + |
| 131 | +<details><summary>➤ Do you want to use <b>XCFrameworks</b>? (Click to read more)</summary> |
| 132 | +<p> |
| 133 | + |
| 134 | +:::caution |
| 135 | +Our XCFrameworks are built with **Swift 5.5**. In order to use them you need **Xcode 13** or above |
| 136 | +::: |
| 137 | + |
| 138 | +You can learn more about [our Module Stable XCFrameworks here](#xcframeworks) |
| 139 | + |
| 140 | +- For the LLC (**StreamChat**) use: |
| 141 | + - `binary "https://raw.githubusercontent.com/GetStream/stream-chat-swift/main/StreamChatArtifacts.json" ~> 4.6` |
| 142 | +- For the UIKit components (**StreamChatUI**, which depends on **StreamChat**) use: |
| 143 | + - `binary "https://raw.githubusercontent.com/GetStream/stream-chat-swift/main/StreamChatArtifacts.json" ~> 4.6` |
| 144 | + |
| 145 | +</p> |
| 146 | +</details> |
| 147 | + |
| 148 | +Now that we’ve modified our Cartfile, let’s go ahead and install the project dependencies via the terminal with one simple command: |
| 149 | + |
| 150 | +```bash |
| 151 | +carthage update --use-xcframeworks |
| 152 | +``` |
| 153 | + |
| 154 | +This command will create pre-built XCFrameworks built from our source code. You now need to add those to your project. |
| 155 | + |
| 156 | +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: |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | +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** |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | +_More information about Carthage [can be found here](https://github.com/Carthage/Carthage)._ |
| 165 | + |
| 166 | +## XCFrameworks |
| 167 | + |
| 168 | +In an effort to have [**Module Stability**](https://www.swift.org/blog/library-evolution/), we have started distributing **pre-built XCFrameworks** starting ***4.6.0*** |
| 169 | + |
| 170 | +:::info |
| 171 | +Our XCFrameworks are built with Swift 5.5. In order to use them you need Xcode 13 or above. |
| 172 | +::: |
| 173 | + |
| 174 | +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. |
| 175 | + |
| 176 | +**Benefits of XCFrameworks:** |
| 177 | +- Conveniently import a single package |
| 178 | +- Supports all platforms and architectures (We support iOS in StreamChatUI and iOS/macOS in StreamChat) |
| 179 | +- No more fat binaries. No more architectures stripping |
| 180 | + |
| 181 | +> Does this mean that from now on, I will need to import Stream manually? |
| 182 | +
|
| 183 | +**No**, [all the known dependency managers support this format](#), and this most likely happens without you even noticing. |
| 184 | + |
| 185 | + |
| 186 | +**Module Stability:** |
| 187 | + |
| 188 | +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). |
0 commit comments