Skip to content

Commit

Permalink
Unpin ably-cocoa
Browse files Browse the repository at this point in the history
This reverts b261155.

Handle ably-cocoa's new commit e216ae5, which reverted the backwards
compatibility-breaking commit 26d9bf7. To handle e216ae5, we need to add
the realtime client's `presence` member to our requirements.
  • Loading branch information
lawrence-forooghian committed Jan 20, 2025
1 parent 4469461 commit a339784
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 32 deletions.
6 changes: 3 additions & 3 deletions AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "20eda2776391659360fe1f5d5d8095daadf2aa748972649241e4432cdb687f89",
"originHash" : "77e4b2b661f9de38584f7d61ba62b95f5fe6ef751d01e208399bed3950246e2b",
"pins" : [
{
"identity" : "ably-cocoa",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ably/ably-cocoa",
"state" : {
"revision" : "5ba7809f5de6e885e8bd4788f0e807f66fc1875b",
"version" : "1.2.36"
"revision" : "35805d0e96a1df5b4dc0f6d82afe22ab753c15bd",
"version" : "1.2.37"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions Example/AblyChatExample/Mocks/MockClients.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ actor MockRoom: Room {
actor MockMessages: Messages {
let clientID: String
let roomID: String
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol

private let mockSubscriptions = MockSubscriptionStorage<Message>()

Expand Down Expand Up @@ -146,7 +146,7 @@ actor MockMessages: Messages {
actor MockRoomReactions: RoomReactions {
let clientID: String
let roomID: String
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol

private let mockSubscriptions = MockSubscriptionStorage<Reaction>()

Expand Down Expand Up @@ -193,7 +193,7 @@ actor MockRoomReactions: RoomReactions {
actor MockTyping: Typing {
let clientID: String
let roomID: String
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol

private let mockSubscriptions = MockSubscriptionStorage<TypingEvent>()

Expand Down Expand Up @@ -356,7 +356,7 @@ actor MockPresence: Presence {
actor MockOccupancy: Occupancy {
let clientID: String
let roomID: String
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol

private let mockSubscriptions = MockSubscriptionStorage<OccupancyEvent>()

Expand Down
100 changes: 97 additions & 3 deletions Example/AblyChatExample/Mocks/MockRealtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ final class MockRealtime: NSObject, RealtimeClientProtocol, Sendable {
fatalError("Not implemented")
}

var presence: ARTRealtimePresenceProtocol {
fatalError("Not implemented")
}
let presence = RealtimePresence()

var errorReason: ARTErrorInfo? {
fatalError("Not implemented")
Expand Down Expand Up @@ -250,6 +248,102 @@ final class MockRealtime: NSObject, RealtimeClientProtocol, Sendable {
}
}

final class RealtimePresence: RealtimePresenceProtocol {
var syncComplete: Bool {
fatalError("Not implemented")
}

func get(_: @escaping ARTPresenceMessagesCallback) {
fatalError("Not implemented")
}

func get(_: ARTRealtimePresenceQuery, callback _: @escaping ARTPresenceMessagesCallback) {
fatalError("Not implemented")
}

func enter(_: Any?) {
fatalError("Not implemented")
}

func enter(_: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func update(_: Any?) {
fatalError("Not implemented")
}

func update(_: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func leave(_: Any?) {
fatalError("Not implemented")
}

func leave(_: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func enterClient(_: String, data _: Any?) {
fatalError("Not implemented")
}

func enterClient(_: String, data _: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func updateClient(_: String, data _: Any?) {
fatalError("Not implemented")
}

func updateClient(_: String, data _: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func leaveClient(_: String, data _: Any?) {
fatalError("Not implemented")
}

func leaveClient(_: String, data _: Any?, callback _: ARTCallback? = nil) {
fatalError("Not implemented")
}

func subscribe(_: @escaping ARTPresenceMessageCallback) -> ARTEventListener? {
fatalError("Not implemented")
}

func subscribe(attachCallback _: ARTCallback?, callback _: @escaping ARTPresenceMessageCallback) -> ARTEventListener? {
fatalError("Not implemented")
}

func subscribe(_: ARTPresenceAction, callback _: @escaping ARTPresenceMessageCallback) -> ARTEventListener? {
fatalError("Not implemented")
}

func subscribe(_: ARTPresenceAction, onAttach _: ARTCallback?, callback _: @escaping ARTPresenceMessageCallback) -> ARTEventListener? {
fatalError("Not implemented")
}

func unsubscribe() {
fatalError("Not implemented")
}

func unsubscribe(_: ARTEventListener) {
fatalError("Not implemented")
}

func unsubscribe(_: ARTPresenceAction, listener _: ARTEventListener) {
fatalError("Not implemented")
}

func history(_: @escaping ARTPaginatedPresenceCallback) {}

func history(_: ARTRealtimeHistoryQuery?, callback _: @escaping ARTPaginatedPresenceCallback) throws {
fatalError("Not implemented")
}
}

required init(options _: ARTClientOptions) {}

required init(key _: String) {}
Expand Down
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "f5dd87027f1300f852cf86019686409a47c851bc11433a4138c8956b8a09ad6f",
"originHash" : "8c7acde3826a921568cc75459ff2052ebec85d53398758c637099c1128f45e32",
"pins" : [
{
"identity" : "ably-cocoa",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ably/ably-cocoa",
"state" : {
"revision" : "5ba7809f5de6e885e8bd4788f0e807f66fc1875b",
"version" : "1.2.36"
"revision" : "35805d0e96a1df5b4dc0f6d82afe22ab753c15bd",
"version" : "1.2.37"
}
},
{
Expand Down
7 changes: 1 addition & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/ably/ably-cocoa",
/*
The upcoming ably-cocoa 1.2.37 will revert a change on which the Chat SDK depends. It will not be possible to make a single version of the Chat SDK work with ably-cocoa versions 1.2.36 and 1.2.37.

So, in order to make sure that the Chat SDK continues to work once ably-cocoa 1.2.37 is released, let's temporarily lock the ably-cocoa dependency to 1.2.36, and release a new version of the Chat SDK. Then, once ably-cocoa 1.2.37 is released, we can release another version of the Chat SDK that requires 1.2.37 and above.
*/
exact: "1.2.36"
from: "1.2.37"
),
.package(
url: "https://github.com/apple/swift-argument-parser",
Expand Down
2 changes: 2 additions & 0 deletions Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ extension ARTRealtimeChannels: RealtimeChannelsProtocol {}

extension ARTRealtimeChannel: RealtimeChannelProtocol {}

extension ARTRealtimePresence: RealtimePresenceProtocol {}

extension ARTConnection: ConnectionProtocol {}
9 changes: 8 additions & 1 deletion Sources/AblyChat/Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ public protocol RealtimeChannelsProtocol: ARTRealtimeChannelsProtocol, Sendable
}

/// Expresses the requirements of the object returned by ``RealtimeChannelsProtocol/get(_:options:)``.
public protocol RealtimeChannelProtocol: ARTRealtimeChannelProtocol, Sendable {}
public protocol RealtimeChannelProtocol: ARTRealtimeChannelProtocol, Sendable {
associatedtype Presence: RealtimePresenceProtocol

var presence: Presence { get }
}

/// Expresses the requirements of the object returned by ``RealtimeChannelProtocol/presence``.
public protocol RealtimePresenceProtocol: ARTRealtimePresenceProtocol, Sendable {}

/// Expresses the requirements of the object returned by ``RealtimeClientProtocol/connection``.
public protocol ConnectionProtocol: ARTConnectionProtocol, Sendable {}
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public protocol Messages: AnyObject, Sendable, EmitsDiscontinuities {
*
* - Returns: The realtime channel.
*/
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }
}

public extension Messages {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/Occupancy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public protocol Occupancy: AnyObject, Sendable, EmitsDiscontinuities {
*
* - Returns: The underlying Ably channel for occupancy events.
*/
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }
}

public extension Occupancy {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/Room.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ internal actor DefaultRoom<LifecycleManagerFactory: RoomLifecycleManagerFactory>
}

private struct FeatureChannelPartialDependencies {
internal var channel: RealtimeChannelProtocol
internal var channel: any RealtimeChannelProtocol
internal var contributor: DefaultRoomLifecycleContributor
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/AblyChat/RoomFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal enum RoomFeature: CaseIterable {
/// - the discontinuities emitted by the room lifecycle
/// - the presence-readiness wait mechanism supplied by the room lifecycle
internal protocol FeatureChannel: Sendable, EmitsDiscontinuities {
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }

/// Waits until we can perform presence operations on the contributors of this room without triggering an implicit attach.
///
Expand All @@ -62,7 +62,7 @@ internal protocol FeatureChannel: Sendable, EmitsDiscontinuities {
}

internal struct DefaultFeatureChannel: FeatureChannel {
internal var channel: RealtimeChannelProtocol
internal var channel: any RealtimeChannelProtocol
internal var contributor: DefaultRoomLifecycleContributor
internal var roomLifecycleManager: RoomLifecycleManager

Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/RoomReactions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public protocol RoomReactions: AnyObject, Sendable, EmitsDiscontinuities {
*
* - Returns: The realtime channel.
*/
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }

/**
* Subscribes a given listener to receive room-level reactions.
Expand Down
2 changes: 1 addition & 1 deletion Sources/AblyChat/Typing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public protocol Typing: AnyObject, Sendable, EmitsDiscontinuities {
*
* - Returns: The Ably realtime channel.
*/
var channel: RealtimeChannelProtocol { get }
var channel: any RealtimeChannelProtocol { get }
}

public extension Typing {
Expand Down
4 changes: 2 additions & 2 deletions Tests/AblyChatTests/Mocks/MockFeatureChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import Ably
@testable import AblyChat

final actor MockFeatureChannel: FeatureChannel {
let channel: RealtimeChannelProtocol
let channel: any RealtimeChannelProtocol
private var discontinuitySubscriptions = SubscriptionStorage<DiscontinuityEvent>()
private let resultOfWaitToBeAbleToPerformPresenceOperations: Result<Void, ARTErrorInfo>?

init(
channel: RealtimeChannelProtocol,
channel: any RealtimeChannelProtocol,
resultOfWaitToBeAblePerformPresenceOperations: Result<Void, ARTErrorInfo>? = nil
) {
self.channel = channel
Expand Down
4 changes: 1 addition & 3 deletions Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import Ably
import AblyChat

final class MockRealtimeChannel: NSObject, RealtimeChannelProtocol {
var presence: ARTRealtimePresenceProtocol {
fatalError("Not implemented")
}
let presence = MockRealtimePresence()

private let attachSerial: String?
private let channelSerial: String?
Expand Down
Loading

0 comments on commit a339784

Please sign in to comment.