Build any realtime experience using Ably's Pub/Sub Cocoa SDK. Supported on all popular platforms and frameworks, including Swift and Objective-C.
Ably Pub/Sub provides flexible APIs that deliver features such as pub-sub messaging, message history, presence, and push notifications. Utilizing Ably's realtime messaging platform, applications benefit from its highly performant, reliable, and scalable infrastructure.
Find out more:
Everything you need to get started with Ably:
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.
The following platforms are supported:
| Platform | Support |
|---|---|
| iOS | >= 10 |
| macOS | >= 10.12 |
| tvOS | >= 10 |
Important
Ably Cocoa SDK versions below 1.2.23 will be deprecated from November 1, 2025.
You can install Ably for iOS and macOS through Swift package manager, CocoaPods, Carthage or install manually.
To use the Ably LiveObjects plugin, see its installation notes below — it is available via Swift Package Manager only.
The Ably Pub/Sub SDK includes installation support for Swift Package Manager.
Swift Package Manager installation details.
To install the ably-cocoa package in your Xcode project:
- Paste
https://github.com/ably/ably-cocoain the Swift Packages search box. ( Xcode project → Swift Packages.. . →+button) - Select the
AblySDK for your target.
To install the ably-cocoa package in another Swift package, add the following to your Package.Swift:
.package(url: "https://github.com/ably/ably-cocoa", from: "1.3.0"),See Apple's adding package dependencies to your app guide for more detail.
The Ably Pub/Sub SDK includes installation support for CocoaPods.
CocoaPods installation details.
If you intend to use Swift, using use_frameworks! in your Podfile is recommended (this will create a Framework that can be used in Swift natively).
Add this line to your application's Podfile:
# For Xcode 7.3 and newer
pod 'Ably', '>= 1.2'And then install the dependency:
$ pod installThe Ably Pub/Sub SDK includes installation support for Carthage.
Carthage installation details.
Add the following line to your application's Cartfile:
# For Xcode 7.3 and newer
github "ably/ably-cocoa" >= 1.2And then run one of the following commands required for your platform:
| Platform | Command |
|---|---|
| iOS | carthage update --use-xcframeworks --platform iOS --no-use-binaries |
| macOS | carthage update --use-xcframeworks --platform macOS --no-use-binaries |
| tvOS | carthage update --use-xcframeworks --platform tvOS --no-use-binaries |
After building the framework (located in [PROJECT_ROOT]/Carthage/Build), drag the following files into the Frameworks, Libraries, and Embedded content section of your Xcode target's General tab:
Ably.xcframeworkAblyDeltaCodec.xcframeworkmsgpack.xcframework- For applications, select Embed & Sign
- For other targets, select Do Not Embed
If you encounter an error similar to the following, you've likely missed adding one or more required dependencies:
dyld: Library not loaded: @rpath/AblyDeltaCodec.framework/AblyDeltaCodec
For further information review the Carthage adding frameworks to an application guide.
The Ably Pub/Sub SDK includes manual installation support.
Manual installation details.
- Download the Ably Pub/Sub Cocoa SDK.
- Drag the
ably-cocoa/ably-cocoadirectory into your Xcode project as a group.
Ably depends on our MessagePack Fork 0.2.0; get it from the releases page and link it into your project.
// Initialize Ably Realtime client
let clientOptions = ARTClientOptions(key: "your-ably-api-key")
clientOptions.clientId = "me"
let realtime = ARTRealtime(options: clientOptions)
// Wait for connection to be established
realtime.connection.on { stateChange in
if stateChange.current == .connected {
print("Connected to Ably")
// Get a reference to the 'test-channel' channel
let channel = realtime.channels.get("test-channel")
// Subscribe to all messages published to this channel
channel.subscribe { message in
print("Received message: \(message.data ?? "")")
}
// Publish a test message to the channel
channel.publish("test-event", data: "hello world!") { error in
guard error == nil else {
print("Error publishing message: \(error!.message)")
return
}
print("Message successfully published")
}
}
}Ably LiveObjects provides realtime, collaborative data structures that automatically synchronize state across all connected clients. This repository contains the Ably LiveObjects plugin, which enables LiveObjects on top of the core Pub/Sub SDK.
Warning
LiveObjects is currently experimental — see the LiveObjects README for details.
The plugin is available via Swift Package Manager only (there is no CocoaPods or Carthage distribution). There is no separate package or version to install: the plugin ships as a product of this package and is versioned and released as part of ably-cocoa.
To install it in your Xcode project, add the ably-cocoa package as above
and additionally select the AblyLiveObjects product for your target.
To install it in another Swift package, add the product to your target's dependencies:
.target(
name: "MyTarget",
dependencies: [
.product(name: "Ably", package: "ably-cocoa"),
.product(name: "AblyLiveObjects", package: "ably-cocoa"),
]
)For usage, platform requirements, the example app and the migration guide for users of the standalone plugin package, see the LiveObjects README.
Read the CONTRIBUTING.md guidelines to contribute to Ably.
The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.
For help or technical support, visit Ably's support page or GitHub Issues for community-reported bugs and discussions.
