Codelabs

Easily Build SwiftUI Chat Applications

by
Jeroen

Jeroen

6 months ago

  • 01

    Introduction

  • 02

    Displaying a List of Channels

  • 03

    Connect the AppDelegate to the app

  • 04

    Adjusting appearance through theming

  • 05

    Displaying Custom Attachment Views

  • 06

    Message Composer Commands

  • 07

    Dig into other customisable components

  • 08

    Congratulations

Codelabs

Easily Build SwiftUI Chat Applications

by
Jeroen

Jeroen

6 months ago

Social image of the event 'Easily Build SwiftUI Chat Applications' - with Stream SDK - Tuesday, March 8th, 9am-11am MST by Jeroen Leenarts

Overview 📖

Welcome to Stream’s Try Swift Workshop! Today, we will be adding Stream’s real-time chat to a SwiftUI application and then we will have some fun modifying the resulting app we created.

By the end of this code lab, you will be able to do the following:

  • Gain a basic understanding of Stream and chat
  • Basic familiarity with Stream Chat API
  • Build a fully functional application using Stream
  • Be able to tweak the look and feel of your App by using the extensive theming options available in our SwiftUI Chat SDK.

Prerequisites 🧬

Before starting this workshop, please ensure you have the following:

  • Git
  • Xcode toolchain installed

Creating a project

To start with the iOS SwiftUI SDK, open Xcode and create a new project.

  • Create a new Swift project in Xcode 13
  • Choose iOS from the list of platforms
  • Choose the "App" template
  • Use SwiftUIChatDemo for the project name
  • Select "SwiftUI" in the Interface option
Image shows Xcode 13 App project being created

We are going to use the Swift Package Manager to fetch the SDK. If you'd like, the SDK can also be installed with CocoaPods. You can find more information on using CocoaPods on the SDK doc pages.

  • Select "Add Packages…" in File menu
  • Paste the URL https://github.com/getstream/stream-chat-swiftui
  • In the option "Dependency Rule" choose "Branch", in the single text input next to it, enter "main" Image shows Xcode 13 package selection with a Github URL and a repository branch
  • Choose "Add Package" and wait for the dialog to complete
  • Only select "StreamChatSwiftUI" and select "Add Package" again Image shows Xcode 13 package selection with a Github URL and a repository branch

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.

You now have an empty project with the SwiftUI SDK as a dependency. Let's get started by displaying some content.

2022 © Stream.io, Inc. All Right Reserved.