AblyChat

2.0.0

Ably Chat SDK for Swift to build chat experiences at scale
ably/ably-chat-swift

What's New

2.0.0

2026-10-30T14:10:08Z

The 2.0.0 release moves the Chat SDK onto version 2 of the Ably Pub/Sub SDK, which is now published as ably-pubsub-cocoa. ably-pubsub-cocoa 2 is a device-side SDK, so a chat client built on it tells Ably that it runs on an end user's device. On an account billed by monthly active users, that traffic counts toward the total, the connection must carry a clientId, and that clientId is subject to a concurrency limit.

A chat client is now created through the createChatClient(pubSubClient:clientOptions:) function, in the same way that a Pub/Sub client is created through PubSubDevice.createClient(options:). This matches the Chat SDKs for other platforms.

Below is an overview of the major changes in this release.

For the changes to the Pub/Sub SDK itself, please refer to the ably-pubsub-cocoa v2 migration guide.

Package and dependencies

  • The SDK depends on ably-pubsub-cocoa 2.x, in place of ably-cocoa 1.x.
  • Import AblyPubSubDevice, which replaces Ably.

Creating clients

  • Create a Pub/Sub client with PubSubDevice.createClient(options:). The ARTRealtime initializer is no longer available.
  • Create a chat client with createChatClient(pubSubClient:clientOptions:). ChatClient's public initializer is removed, and ChatClientOptions is unchanged.

Chat client API

  • ChatClient.realtime is renamed to pubSubClient, and its type is PubSubClient in place of ARTRealtime.
  • On ChatClientProtocol, the realtime property is renamed to pubSubClient, and the Realtime associated type is renamed to PubSubClient.
  • ChatClient.rooms is some Rooms<RealtimeChannel>, in place of some Rooms<ARTRealtimeChannel>.

Swift API

  • Swift sees the Pub/Sub SDK's types without the ART prefix: ARTClientOptions is ClientOptions, ARTRealtimeChannel is RealtimeChannel, and so on.
  • Some of these names are also used by the Chat SDK, such as Message, ErrorInfo and Presence. In a file that imports both AblyChat and AblyPubSubDevice, qualify the type with its module name, for example AblyChat.Message.

Migration example

// Before
import Ably
import AblyChat

let realtimeOptions = ARTClientOptions()
realtimeOptions.key = "<your-ably-api-key>"
realtimeOptions.clientId = "your-client-id"
let realtime = ARTRealtime(options: realtimeOptions)
let chatClient = ChatClient(realtime: realtime, clientOptions: ChatClientOptions())

// After
import AblyChat
import AblyPubSubDevice

let clientOptions = ClientOptions()
clientOptions.key = "<your-ably-api-key>"
clientOptions.clientId = "your-client-id"
let pubSubClient = PubSubDevice.createClient(options: clientOptions)
let chatClient = createChatClient(pubSubClient: pubSubClient, clientOptions: ChatClientOptions())

Supported platforms changes

  • Support for macOS earlier than 12, iOS earlier than 15 and tvOS earlier than 15 has been dropped.

Full Changelog: 1.2.1...2.0.0

Ably Chat Swift Header SPM Swift Compatibility License


Ably Chat Swift SDK

Ably Chat is a set of purpose-built APIs for a host of chat features enabling you to create 1:1, 1:Many, Many:1 and Many:Many chat rooms for any scale. It is designed to meet a wide range of chat use cases, such as livestreams, in-game communication, customer support, or social interactions in SaaS products. Built on Ably's core service, it abstracts complex details to enable efficient chat architectures.


Getting started

Everything you need to get started with Ably:


Supported platforms

Ably aims to support a wide range of platforms. If you experience any compatibility issues, open an issue in the repository or contact Ably support.

This SDK supports the following platforms:

Platform Support
iOS >= 15.0
macOS >= 12.0
tvOS >= 15.0

Note

Xcode 26.0 or later is required.


Installation

The SDK is distributed as a Swift Package and can be installed using Xcode or by adding it as a dependency in your package's Package.swift.

Using Xcode

To install the ably-chat-swift package in your Xcode Project:

  1. Open your Xcode project and navigate to File → Add Package Dependencies...
  2. Paste https://github.com/ably/ably-chat-swift in the search box
  3. Select the version you want to use
  4. Select the Ably Chat SDK for your target

Using Swift Package Manager

To install the ably-chat-swift package in another Swift Package, add the following to your Package.swift:

.package(url: "https://github.com/ably/ably-chat-swift", from: "2.0.0"),

Usage

The following code connects to Ably's chat service, subscribes to a chat room, and sends a message to that room:

import AblyChat
import AblyPubSubDevice

// Initialize the Ably Pub/Sub client
let clientOptions = ClientOptions()
clientOptions.key = "<your-ably-api-key>"
clientOptions.clientId = "your-client-id"
let pubSubClient = PubSubDevice.createClient(options: clientOptions)

// Create a chat client
let chatClient = createChatClient(pubSubClient: pubSubClient, clientOptions: ChatClientOptions())

// Get a chat room
let room = try await chatClient.rooms.get(named: "my-room", options: RoomOptions())

// Monitor room status
room.onStatusChange { statusChange in
    switch statusChange.current {
    case .attached:
        print("Room is attached")
    case .detached:
        print("Room is detached")
    case .failed(let error):
        print("Room failed: \(error)")
    default:
        print("Room status: \(statusChange.current)")
    }
}

// Attach to the room
try await room.attach()

// Subscribe to messages
let subscription = room.messages.subscribe { event in
    print("Received message: \(event.message.text)")
}

// Send a message
try await room.messages.send(withParams: SendMessageParams(text: "Hello, World!"))

Releases

The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.


Contribute

Read the CONTRIBUTING.md guidelines to contribute to Ably or share feedback or request a new feature.

Support, feedback and troubleshooting

For help or technical support, visit Ably's support page. You can also view the community reported Github issues or raise one yourself.

Description

  • Swift Tools 6.2.0
View More Packages from this Author

Dependencies

Last updated: Sun Nov 08 2026 07:41:17 GMT-1000 (Hawaii-Aleutian Standard Time)