Repository navigation
The 2.0.0 release makes ably-cocoa a device-side SDK, for apps that run on an end user's device. A client is created through PubSubDevice.createClient, and every client it creates tells Ably that it runs on a device. That declaration determines how its traffic is counted: on an account billed by monthly active users, device traffic counts toward the total, the connection must carry a clientId, and that clientId is subject to a concurrency limit.
The repository is renamed to ably-pubsub-cocoa, and the package is distributed through Swift Package Manager only. In Swift, a new AblyPubSubDeviceSwift module adds async versions of channel and presence operations.
2.0 also brings the public API in line with the Ably client library specification: it renames types, removes the APIs deprecated in 1.x, and corrects types and nullability.
Below is an overview of the major changes in this release.
Please refer to the v2 migration guide for the full details, including a list of all breaking changes and instructions on how to address them.
Repository, package and distribution
- Add the package from
https://github.com/ably/ably-pubsub-cocoa. The old URL,https://github.com/ably/ably-cocoa, serves the 1.x line, which receives security and critical fixes only. - Swift Package Manager is the only distribution channel. 2.0 ships no CocoaPods pod and no Carthage framework, and both stay on the 1.x line.
- The SDK is the
AblyPubSubDeviceproduct, which replacesAbly. The package also vendsAblyLiveObjects, released at the same version. - In Swift, import
AblyPubSubDeviceSwift. In Objective-C, importAblyPubSubDevice.
Creating clients
- Create a client with
PubSubDevice.createClient(options:),createClient(key:)orcreateClient(token:). - The client class's initializers are no longer public, and the
createWithOptions:,createWithKey:andcreateWithToken:class factories are removed. - The SDK identifies itself to Ably as
ably-pubsub-cocoa, where 1.x sentably-cocoa. A client fromPubSubDevice.createClientalso sends a versionlessably-pubsub-deviceentry.
Swift API
- Swift sees the SDK's types without the
ARTprefix:ARTClientOptionsisClientOptions,ARTErrorInfoisErrorInfo, and so on. Objective-C keeps the prefix. AblyPubSubDeviceSwiftaddsasyncversions of operations such asattach,publishand presenceenter, which throw anErrorInfo.
Client API naming
ARTRealtimeis renamedARTPubSubClient, andARTRealtimeProtocolis renamedARTPubSubProtocol.ARTRestis renamedARTHttpClient, along withARTHttpChannel,ARTHttpChannels,ARTHttpPresenceandARTHttpAnnotations. These classes are now internal. An application reaches Ably through the realtime client.
Client options
endpointreplaces theenvironment,restHostandrealtimeHostoptions, which are removed. A client that sets none of them connects tomain.realtime.ably.net, with fallbacks atmain.[a-e].fallback.ably-realtime.com.realtimeRequestTimeoutandmaxMessageSizemove fromARTDefaulttoARTClientOptions, so each client can set its own.maxFrameSizeis a new option.- With an empty
fallbackHostsarray, an unreachable host no longer fails the connection. The connection moves to DISCONNECTED and retries.
Types and nullability
ARTStatshas no typed properties. Every statistic is inentries, keyed by its name.extrasis a dictionary on messages, presence messages and annotations.ARTCrypto.getDefaultParams:takes anARTCipherParamOptions, and a dictionary can no longer be passed as a channel'scipher.ARTDevicePushDetails.stateis anARTDevicePushStateenum.ARTMessageVersionandARTMessageAnnotationsare immutable andSendable.Message.version,Message.annotations,Annotation.timestampand the listener thatsubscribereturns are no longer optional.Message.connectionIdis now optional.- When a system error stops an operation, the
ErrorInfohas an Ably error code, and the system error is its underlying error.
Behaviour changes
channels.release()throws unless the channel isinitialized,detachedorfailed. Detach a channel before releasing it.- Invalid arguments to
history,stats,requestand pushlistSubscriptionsraiseNSInvalidArgumentException, and those methods no longer return an error. - Subscribing on a channel in the FAILED state registers the listener.
- The client falls back to another host after a
DISCONNECTEDwith a 5xx error, or after a CloudFront error response.
Removed APIs
- The members deprecated in 1.x:
fallbackHostsUseDefault,ARTConnection.recoveryKeyandARTStats.intervalGranularity. - The
publishoverloads that takeclientIdorextrasalongsidenameanddata. Set them on aMessageinstead. didAblyPushRegistrationFail:. ImplementdidUpdateAblyPush:instead.ARTDataQueryError,ARTRealtimeHistoryErrorandARTCustomRequestError.
Supported platforms changes
- Support for macOS earlier than 12, iOS earlier than 15 and tvOS earlier than 15 has been dropped.
- Building the SDK requires Xcode 26 or later (Swift 6.2).