From de49b6705f470dfde272384918b447c7cc37420c Mon Sep 17 00:00:00 2001 From: Marat Al Date: Fri, 23 Aug 2024 12:40:52 +0200 Subject: [PATCH 1/7] I've added `NS_SWIFT_SENDABLE` to every type that has a docstring and their accompanied enums and params types (issue #1962). --- Source/include/Ably/ARTAuth.h | 1 + Source/include/Ably/ARTAuthDetails.h | 1 + Source/include/Ably/ARTAuthOptions.h | 1 + Source/include/Ably/ARTChannel.h | 1 + Source/include/Ably/ARTChannelOptions.h | 1 + Source/include/Ably/ARTChannels.h | 1 + Source/include/Ably/ARTClientOptions.h | 1 + Source/include/Ably/ARTConnection.h | 1 + Source/include/Ably/ARTConnectionDetails.h | 1 + Source/include/Ably/ARTDataQuery.h | 3 +++ Source/include/Ably/ARTDeviceDetails.h | 1 + .../include/Ably/ARTDeviceIdentityTokenDetails.h | 1 + Source/include/Ably/ARTDevicePushDetails.h | 1 + Source/include/Ably/ARTEventEmitter.h | 2 ++ Source/include/Ably/ARTHTTPPaginatedResponse.h | 1 + Source/include/Ably/ARTLocalDevice.h | 1 + Source/include/Ably/ARTMessage.h | 1 + Source/include/Ably/ARTPaginatedResult.h | 1 + Source/include/Ably/ARTPresence.h | 1 + Source/include/Ably/ARTPresenceMessage.h | 2 ++ Source/include/Ably/ARTPush.h | 1 + Source/include/Ably/ARTPushAdmin.h | 1 + Source/include/Ably/ARTPushChannel.h | 1 + Source/include/Ably/ARTPushChannelSubscription.h | 1 + Source/include/Ably/ARTPushChannelSubscriptions.h | 1 + Source/include/Ably/ARTPushDeviceRegistrations.h | 1 + Source/include/Ably/ARTRealtime.h | 1 + Source/include/Ably/ARTRealtimeChannel.h | 1 + Source/include/Ably/ARTRealtimeChannelOptions.h | 2 ++ Source/include/Ably/ARTRealtimePresence.h | 2 ++ Source/include/Ably/ARTRest.h | 1 + Source/include/Ably/ARTRestChannel.h | 1 + Source/include/Ably/ARTRestPresence.h | 2 ++ Source/include/Ably/ARTStats.h | 10 ++++++++++ Source/include/Ably/ARTStatus.h | 3 +++ Source/include/Ably/ARTTokenDetails.h | 1 + Source/include/Ably/ARTTokenParams.h | 1 + Source/include/Ably/ARTTokenRequest.h | 1 + Source/include/Ably/ARTTypes.h | 15 +++++++++++++++ 39 files changed, 71 insertions(+) diff --git a/Source/include/Ably/ARTAuth.h b/Source/include/Ably/ARTAuth.h index 3f1b8f35e..b7195c59b 100644 --- a/Source/include/Ably/ARTAuth.h +++ b/Source/include/Ably/ARTAuth.h @@ -88,6 +88,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTAuthProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTAuth : NSObject @end diff --git a/Source/include/Ably/ARTAuthDetails.h b/Source/include/Ably/ARTAuthDetails.h index 46ee9d7df..6886334ad 100644 --- a/Source/include/Ably/ARTAuthDetails.h +++ b/Source/include/Ably/ARTAuthDetails.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the token string used to authenticate a client with Ably. */ +NS_SWIFT_SENDABLE @interface ARTAuthDetails : NSObject /** diff --git a/Source/include/Ably/ARTAuthOptions.h b/Source/include/Ably/ARTAuthOptions.h index 511de7fb2..3461e9d2e 100644 --- a/Source/include/Ably/ARTAuthOptions.h +++ b/Source/include/Ably/ARTAuthOptions.h @@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes authentication-specific properties in authentication requests to Ably. Properties set using `ARTAuthOptions` are used instead of the default values set when the client library is instantiated, as opposed to being merged with them. */ +NS_SWIFT_SENDABLE @interface ARTAuthOptions : NSObject /** diff --git a/Source/include/Ably/ARTChannel.h b/Source/include/Ably/ARTChannel.h index fbd6393da..cb063f557 100644 --- a/Source/include/Ably/ARTChannel.h +++ b/Source/include/Ably/ARTChannel.h @@ -79,6 +79,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTChannelProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTChannel : NSObject /// :nodoc: diff --git a/Source/include/Ably/ARTChannelOptions.h b/Source/include/Ably/ARTChannelOptions.h index f7028d517..a66b64d7b 100644 --- a/Source/include/Ably/ARTChannelOptions.h +++ b/Source/include/Ably/ARTChannelOptions.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes additional properties to an `ARTRestChannel` object, such as encryption. */ +NS_SWIFT_SENDABLE @interface ARTChannelOptions : NSObject /** diff --git a/Source/include/Ably/ARTChannels.h b/Source/include/Ably/ARTChannels.h index 03ac7bbba..bc0d3610d 100644 --- a/Source/include/Ably/ARTChannels.h +++ b/Source/include/Ably/ARTChannels.h @@ -7,6 +7,7 @@ /** * Creates and destroys `ARTRestChannel` and `ARTRealtimeChannel` objects. */ +NS_SWIFT_SENDABLE @interface ARTChannels : NSObject /** diff --git a/Source/include/Ably/ARTClientOptions.h b/Source/include/Ably/ARTClientOptions.h index 572983a6c..59a4e6749 100644 --- a/Source/include/Ably/ARTClientOptions.h +++ b/Source/include/Ably/ARTClientOptions.h @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes additional client-specific properties to the REST `-[ARTRestProtocol initWithOptions:]` or the Realtime `-[ARTRealtimeProtocol initWithOptions:]`. */ +NS_SWIFT_SENDABLE @interface ARTClientOptions : ARTAuthOptions /** diff --git a/Source/include/Ably/ARTConnection.h b/Source/include/Ably/ARTConnection.h index aa25e2f56..ac61a970d 100644 --- a/Source/include/Ably/ARTConnection.h +++ b/Source/include/Ably/ARTConnection.h @@ -80,6 +80,7 @@ ART_EMBED_INTERFACE_EVENT_EMITTER(ARTRealtimeConnectionEvent, ARTConnectionState * * @see See `ARTConnectionProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTConnection: NSObject @end diff --git a/Source/include/Ably/ARTConnectionDetails.h b/Source/include/Ably/ARTConnectionDetails.h index 7121ebd60..61b798e30 100644 --- a/Source/include/Ably/ARTConnectionDetails.h +++ b/Source/include/Ably/ARTConnectionDetails.h @@ -5,6 +5,7 @@ /** * Contains any constraints a client should adhere to and provides additional metadata about a `ARTConnection`, such as if a request to `-[ARTChannelProtocol publish:callback:]` a message that exceeds the maximum message size should be rejected immediately without communicating with Ably. */ +NS_SWIFT_SENDABLE @interface ARTConnectionDetails : NSObject NS_ASSUME_NONNULL_BEGIN diff --git a/Source/include/Ably/ARTDataQuery.h b/Source/include/Ably/ARTDataQuery.h index 6f9d8ccbd..78034fc83 100755 --- a/Source/include/Ably/ARTDataQuery.h +++ b/Source/include/Ably/ARTDataQuery.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTQueryDirection) { ARTQueryDirectionForwards, ARTQueryDirectionBackwards @@ -13,6 +14,7 @@ typedef NS_ENUM(NSUInteger, ARTQueryDirection) { /** This object is used for providing parameters into methods with paginated results. */ +NS_SWIFT_SENDABLE @interface ARTDataQuery : NSObject /** @@ -40,6 +42,7 @@ typedef NS_ENUM(NSUInteger, ARTQueryDirection) { /** This object is used for providing parameters into `ARTRealtimePresence`'s methods with paginated results. */ +NS_SWIFT_SENDABLE @interface ARTRealtimeHistoryQuery : ARTDataQuery /** diff --git a/Source/include/Ably/ARTDeviceDetails.h b/Source/include/Ably/ARTDeviceDetails.h index b996fc99c..798d43252 100644 --- a/Source/include/Ably/ARTDeviceDetails.h +++ b/Source/include/Ably/ARTDeviceDetails.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the properties of a device registered for push notifications. */ +NS_SWIFT_SENDABLE @interface ARTDeviceDetails : NSObject /** diff --git a/Source/include/Ably/ARTDeviceIdentityTokenDetails.h b/Source/include/Ably/ARTDeviceIdentityTokenDetails.h index 5e2463dd3..00ea3b6bf 100644 --- a/Source/include/Ably/ARTDeviceIdentityTokenDetails.h +++ b/Source/include/Ably/ARTDeviceIdentityTokenDetails.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /** * An object representing a unique device identity token used to communicate with APNS. */ +NS_SWIFT_SENDABLE @interface ARTDeviceIdentityTokenDetails : NSObject /** diff --git a/Source/include/Ably/ARTDevicePushDetails.h b/Source/include/Ably/ARTDevicePushDetails.h index 3822cd595..0b2297f57 100644 --- a/Source/include/Ably/ARTDevicePushDetails.h +++ b/Source/include/Ably/ARTDevicePushDetails.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the details of the push registration of a device. */ +NS_SWIFT_SENDABLE @interface ARTDevicePushDetails : NSObject /** diff --git a/Source/include/Ably/ARTEventEmitter.h b/Source/include/Ably/ARTEventEmitter.h index d6d20a293..ea20e2fc8 100644 --- a/Source/include/Ably/ARTEventEmitter.h +++ b/Source/include/Ably/ARTEventEmitter.h @@ -23,12 +23,14 @@ NS_ASSUME_NONNULL_BEGIN /** An object representing a listener returned by `ARTEventEmitter` methods. */ +NS_SWIFT_SENDABLE @interface ARTEventListener : NSObject @end /** * A generic interface for event registration and delivery used in a number of the types in the Realtime client library. For example, the `ARTConnection` and `ARTRealtimeChannel` objects emit events for their state using the `ARTEventEmitter` pattern. */ +NS_SWIFT_SENDABLE @interface ARTEventEmitter, ItemType> : NSObject /// :nodoc: diff --git a/Source/include/Ably/ARTHTTPPaginatedResponse.h b/Source/include/Ably/ARTHTTPPaginatedResponse.h index 25ddbcae9..dded73d0b 100644 --- a/Source/include/Ably/ARTHTTPPaginatedResponse.h +++ b/Source/include/Ably/ARTHTTPPaginatedResponse.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A superset of `ARTPaginatedResult` which represents a page of results plus metadata indicating the relative queries available to it. `ARTHttpPaginatedResponse` additionally carries information about the response to an HTTP request. */ +NS_SWIFT_SENDABLE @interface ARTHTTPPaginatedResponse : ARTPaginatedResult /** diff --git a/Source/include/Ably/ARTLocalDevice.h b/Source/include/Ably/ARTLocalDevice.h index 25ef79639..a5d11ab7e 100644 --- a/Source/include/Ably/ARTLocalDevice.h +++ b/Source/include/Ably/ARTLocalDevice.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the device identity token and secret of a device. `ARTLocalDevice` extends `ARTDeviceDetails`. */ +NS_SWIFT_SENDABLE @interface ARTLocalDevice : ARTDeviceDetails /** diff --git a/Source/include/Ably/ARTMessage.h b/Source/include/Ably/ARTMessage.h index 88d145170..7c05338d8 100644 --- a/Source/include/Ably/ARTMessage.h +++ b/Source/include/Ably/ARTMessage.h @@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains an individual message that is sent to, or received from, Ably. */ +NS_SWIFT_SENDABLE @interface ARTMessage : ARTBaseMessage /// The event name, if available diff --git a/Source/include/Ably/ARTPaginatedResult.h b/Source/include/Ably/ARTPaginatedResult.h index f215f6c6f..a5b73561f 100644 --- a/Source/include/Ably/ARTPaginatedResult.h +++ b/Source/include/Ably/ARTPaginatedResult.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains a page of results for message or presence history, stats, or REST presence requests. An `ARTPaginatedResult` response from a REST API paginated query is also accompanied by metadata that indicates the relative queries available to the `ARTPaginatedResult` object. */ +NS_SWIFT_SENDABLE @interface ARTPaginatedResult : NSObject /** diff --git a/Source/include/Ably/ARTPresence.h b/Source/include/Ably/ARTPresence.h index e3589105d..8b3b4c88d 100644 --- a/Source/include/Ably/ARTPresence.h +++ b/Source/include/Ably/ARTPresence.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_SENDABLE @interface ARTPresence : NSObject - (void)history:(ARTPaginatedPresenceCallback)callback; diff --git a/Source/include/Ably/ARTPresenceMessage.h b/Source/include/Ably/ARTPresenceMessage.h index a97411136..c730c6667 100644 --- a/Source/include/Ably/ARTPresenceMessage.h +++ b/Source/include/Ably/ARTPresenceMessage.h @@ -4,6 +4,7 @@ /** * Describes the possible actions members in the presence set can emit. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTPresenceAction) { /** * A member is not present in the channel. @@ -35,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains an individual presence update sent to, or received from, Ably. */ +NS_SWIFT_SENDABLE @interface ARTPresenceMessage : ARTBaseMessage /** diff --git a/Source/include/Ably/ARTPush.h b/Source/include/Ably/ARTPush.h index 81b414995..fd5154d0c 100644 --- a/Source/include/Ably/ARTPush.h +++ b/Source/include/Ably/ARTPush.h @@ -111,6 +111,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables a device to be registered and deregistered from receiving push notifications. */ +NS_SWIFT_SENDABLE @interface ARTPush : NSObject /** diff --git a/Source/include/Ably/ARTPushAdmin.h b/Source/include/Ably/ARTPushAdmin.h index 27af1a2f4..2c0d724e4 100644 --- a/Source/include/Ably/ARTPushAdmin.h +++ b/Source/include/Ably/ARTPushAdmin.h @@ -27,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables the management of device registrations and push notification subscriptions. Also enables the publishing of push notifications to devices. */ +NS_SWIFT_SENDABLE @interface ARTPushAdmin : NSObject /** diff --git a/Source/include/Ably/ARTPushChannel.h b/Source/include/Ably/ARTPushChannel.h index ce2551ea0..c6070c46c 100644 --- a/Source/include/Ably/ARTPushChannel.h +++ b/Source/include/Ably/ARTPushChannel.h @@ -83,6 +83,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushChannelProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTPushChannel : NSObject @end diff --git a/Source/include/Ably/ARTPushChannelSubscription.h b/Source/include/Ably/ARTPushChannelSubscription.h index eb89e72a2..9c0f06273 100644 --- a/Source/include/Ably/ARTPushChannelSubscription.h +++ b/Source/include/Ably/ARTPushChannelSubscription.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the subscriptions of a device, or a group of devices sharing the same `clientId`, has to a channel in order to receive push notifications. */ +NS_SWIFT_SENDABLE @interface ARTPushChannelSubscription : NSObject /** diff --git a/Source/include/Ably/ARTPushChannelSubscriptions.h b/Source/include/Ably/ARTPushChannelSubscriptions.h index af06f0f08..eeeda92d6 100644 --- a/Source/include/Ably/ARTPushChannelSubscriptions.h +++ b/Source/include/Ably/ARTPushChannelSubscriptions.h @@ -62,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushChannelSubscriptionsProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTPushChannelSubscriptions : NSObject @end diff --git a/Source/include/Ably/ARTPushDeviceRegistrations.h b/Source/include/Ably/ARTPushDeviceRegistrations.h index 1738b9863..29fb1ae86 100644 --- a/Source/include/Ably/ARTPushDeviceRegistrations.h +++ b/Source/include/Ably/ARTPushDeviceRegistrations.h @@ -61,6 +61,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushDeviceRegistrationsProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTPushDeviceRegistrations : NSObject @end diff --git a/Source/include/Ably/ARTRealtime.h b/Source/include/Ably/ARTRealtime.h index fbf87b8b8..1eb23fd1b 100644 --- a/Source/include/Ably/ARTRealtime.h +++ b/Source/include/Ably/ARTRealtime.h @@ -104,6 +104,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A client that extends the functionality of the `ARTRest` and provides additional realtime-specific features. */ +NS_SWIFT_SENDABLE @interface ARTRealtime : NSObject /** diff --git a/Source/include/Ably/ARTRealtimeChannel.h b/Source/include/Ably/ARTRealtimeChannel.h index 6a153d8aa..baad506ab 100644 --- a/Source/include/Ably/ARTRealtimeChannel.h +++ b/Source/include/Ably/ARTRealtimeChannel.h @@ -149,6 +149,7 @@ ART_EMBED_INTERFACE_EVENT_EMITTER(ARTChannelEvent, ARTChannelStateChange *) * Enables messages to be published and subscribed to. Also enables historic messages to be retrieved and provides access to the `ARTRealtimePresence` object of a channel. * Also implements `ARTEventEmitter` interface and emits `ARTChannelEvent` events, where a `ARTChannelEvent` is either a `ARTRealtimeChannelState` or an `ARTChannelEvent.ARTChannelEventUpdate`. */ +NS_SWIFT_SENDABLE @interface ARTRealtimeChannel : NSObject /** diff --git a/Source/include/Ably/ARTRealtimeChannelOptions.h b/Source/include/Ably/ARTRealtimeChannelOptions.h index 2e5618d12..af43dc8b6 100644 --- a/Source/include/Ably/ARTRealtimeChannelOptions.h +++ b/Source/include/Ably/ARTRealtimeChannelOptions.h @@ -5,6 +5,7 @@ /** * Describes the possible flags used to configure client capabilities, using `ARTChannelOptions`. */ +NS_SWIFT_SENDABLE typedef NS_OPTIONS(NSUInteger, ARTChannelMode) { /** * The client can enter the presence set. @@ -29,6 +30,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes additional properties to an `ARTRealtimeChannel` object, such as encryption, an `ARTChannelMode` and channel parameters. */ +NS_SWIFT_SENDABLE @interface ARTRealtimeChannelOptions : ARTChannelOptions /** diff --git a/Source/include/Ably/ARTRealtimePresence.h b/Source/include/Ably/ARTRealtimePresence.h index 6e22ef459..003916b2b 100644 --- a/Source/include/Ably/ARTRealtimePresence.h +++ b/Source/include/Ably/ARTRealtimePresence.h @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN /** This object is used for providing parameters into `ARTRealtimePresence`'s methods with paginated results. */ +NS_SWIFT_SENDABLE @interface ARTRealtimePresenceQuery : ARTPresenceQuery /** @@ -217,6 +218,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTRealtimePresenceProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTRealtimePresence : ARTPresence @end diff --git a/Source/include/Ably/ARTRest.h b/Source/include/Ably/ARTRest.h index ca9dbd0de..f1235a3d2 100644 --- a/Source/include/Ably/ARTRest.h +++ b/Source/include/Ably/ARTRest.h @@ -99,6 +99,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A client that offers a simple stateless API to interact directly with Ably's REST API. */ +NS_SWIFT_SENDABLE @interface ARTRest : NSObject /** diff --git a/Source/include/Ably/ARTRestChannel.h b/Source/include/Ably/ARTRestChannel.h index 2c25a3a2e..941c52b80 100644 --- a/Source/include/Ably/ARTRestChannel.h +++ b/Source/include/Ably/ARTRestChannel.h @@ -46,6 +46,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables messages to be published and historic messages to be retrieved for a channel. */ +NS_SWIFT_SENDABLE @interface ARTRestChannel : NSObject /** diff --git a/Source/include/Ably/ARTRestPresence.h b/Source/include/Ably/ARTRestPresence.h index 0d24c00dc..83abb34c9 100644 --- a/Source/include/Ably/ARTRestPresence.h +++ b/Source/include/Ably/ARTRestPresence.h @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN /** This object is used for providing parameters into `ARTRestPresence`'s methods with paginated results. */ +NS_SWIFT_SENDABLE @interface ARTPresenceQuery : NSObject /** @@ -78,6 +79,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTRestPresenceProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTRestPresence : ARTPresence @end diff --git a/Source/include/Ably/ARTStats.h b/Source/include/Ably/ARTStats.h index e05a5b342..d174178bd 100644 --- a/Source/include/Ably/ARTStats.h +++ b/Source/include/Ably/ARTStats.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Describes the interval unit over which statistics are gathered. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Interval unit over which statistics are gathered as minutes. @@ -29,6 +30,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** This object is used for providing parameters into `ARTStats`'s methods with paginated results. */ +NS_SWIFT_SENDABLE @interface ARTStatsQuery : ARTDataQuery /** @@ -41,6 +43,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains the aggregate counts for messages and data transferred. */ +NS_SWIFT_SENDABLE @interface ARTStatsMessageCount : NSObject /** @@ -68,6 +71,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains a breakdown of summary stats data for different (channel vs presence) message types. */ +NS_SWIFT_SENDABLE @interface ARTStatsMessageTypes : NSObject /** @@ -101,6 +105,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains a breakdown of summary stats data for traffic over various transport types. */ +NS_SWIFT_SENDABLE @interface ARTStatsMessageTraffic : NSObject /** @@ -140,6 +145,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains the aggregate data for usage of a resource in a specific scope. */ +NS_SWIFT_SENDABLE @interface ARTStatsResourceCount : NSObject /** @@ -185,6 +191,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains a breakdown of summary stats data for different (`TLS` vs non-`TLS`) connection types. */ +NS_SWIFT_SENDABLE @interface ARTStatsConnectionTypes : NSObject /** @@ -218,6 +225,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains the aggregate counts for requests made. */ +NS_SWIFT_SENDABLE @interface ARTStatsRequestCount : NSObject /** @@ -251,6 +259,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Details the stats on push notifications. */ +NS_SWIFT_SENDABLE @interface ARTStatsPushCount : NSObject /** @@ -302,6 +311,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains application statistics for a specified time interval and time period. */ +NS_SWIFT_SENDABLE @interface ARTStats : NSObject /// :nodoc: diff --git a/Source/include/Ably/ARTStatus.h b/Source/include/Ably/ARTStatus.h index c36e83c8c..60bde777c 100644 --- a/Source/include/Ably/ARTStatus.h +++ b/Source/include/Ably/ARTStatus.h @@ -27,6 +27,7 @@ typedef NS_ENUM(NSUInteger, ARTState) { /** The list of all public error codes returned under the error domain ARTAblyErrorDomain */ +NS_SWIFT_SENDABLE typedef CF_ENUM(NSUInteger, ARTErrorCode) { ARTErrorNoError = 10000, ARTErrorBadRequest = 40000, @@ -189,6 +190,7 @@ FOUNDATION_EXPORT NSString *const ARTAblyMessageNoMeansToRenewToken; * * @see For possible `NSError.code` see Ably [error codes](https://github.com/ably/ably-common/blob/main/protocol/errors.json). */ +NS_SWIFT_SENDABLE @interface ARTErrorInfo : NSError /** @@ -257,6 +259,7 @@ FOUNDATION_EXPORT NSString *const ARTAblyMessageNoMeansToRenewToken; * :nodoc: TODO: docstring * An object representing a status of an operation. */ +NS_SWIFT_SENDABLE @interface ARTStatus : NSObject @property (nullable, readonly, nonatomic) ARTErrorInfo *errorInfo; diff --git a/Source/include/Ably/ARTTokenDetails.h b/Source/include/Ably/ARTTokenDetails.h index 316d6e52c..e8a1220f0 100644 --- a/Source/include/Ably/ARTTokenDetails.h +++ b/Source/include/Ably/ARTTokenDetails.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains an Ably Token and its associated metadata. */ +NS_SWIFT_SENDABLE @interface ARTTokenDetails : NSObject /** diff --git a/Source/include/Ably/ARTTokenParams.h b/Source/include/Ably/ARTTokenParams.h index a7877268c..0cdf264dd 100644 --- a/Source/include/Ably/ARTTokenParams.h +++ b/Source/include/Ably/ARTTokenParams.h @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Defines the properties of an Ably Token. */ +NS_SWIFT_SENDABLE @interface ARTTokenParams : NSObject /** diff --git a/Source/include/Ably/ARTTokenRequest.h b/Source/include/Ably/ARTTokenRequest.h index 853783f87..4793694b0 100644 --- a/Source/include/Ably/ARTTokenRequest.h +++ b/Source/include/Ably/ARTTokenRequest.h @@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the properties of a request for a token to Ably. Tokens are generated using `-[ARTAuthProtocol requestToken:]`. */ +NS_SWIFT_SENDABLE @interface ARTTokenRequest : NSObject /** diff --git a/Source/include/Ably/ARTTypes.h b/Source/include/Ably/ARTTypes.h index afdcda17a..3c40d6dc1 100644 --- a/Source/include/Ably/ARTTypes.h +++ b/Source/include/Ably/ARTTypes.h @@ -34,6 +34,7 @@ typedef NSData ARTDeviceToken; typedef ARTJsonObject ARTPushRecipient; /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTAuthentication) { ARTAuthenticationOff, ARTAuthenticationOn, @@ -43,6 +44,7 @@ typedef NS_ENUM(NSUInteger, ARTAuthentication) { }; /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTAuthMethod) { ARTAuthMethodBasic, ARTAuthMethodToken @@ -51,6 +53,7 @@ typedef NS_ENUM(NSUInteger, ARTAuthMethod) { /** * Describes the realtime `ARTConnection` object states. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTRealtimeConnectionState) { /** * A connection with this state has been initialized but no connection has yet been attempted. @@ -92,6 +95,7 @@ NSString *_Nonnull ARTRealtimeConnectionStateToStr(ARTRealtimeConnectionState st /** * Describes the events emitted by a `ARTConnection` object. An event is either an `ARTRealtimeConnectionEventUpdate` or an `ARTRealtimeConnectionState`. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTRealtimeConnectionEvent) { ARTRealtimeConnectionEventInitialized, ARTRealtimeConnectionEventConnecting, @@ -113,6 +117,7 @@ NSString *_Nonnull ARTRealtimeConnectionEventToStr(ARTRealtimeConnectionEvent ev /** * Describes the possible states of an `ARTRealtimeChannel` object. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTRealtimeChannelState) { /** * The channel has been initialized but no attach has yet been attempted. @@ -150,6 +155,7 @@ NSString *_Nonnull ARTRealtimeChannelStateToStr(ARTRealtimeChannelState state); /** * Describes the events emitted by an `ARTRealtimeChannel` object. An event is either an `ARTChannelEventUpdate` or a `ARTRealtimeChannelState`. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTChannelEvent) { ARTChannelEventInitialized, ARTChannelEventAttaching, @@ -169,6 +175,7 @@ NSString *_Nonnull ARTChannelEventToStr(ARTChannelEvent event); /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSInteger, ARTDataQueryError) { ARTDataQueryErrorLimit = 1, ARTDataQueryErrorTimestampRange = 2, @@ -178,11 +185,13 @@ typedef NS_ENUM(NSInteger, ARTDataQueryError) { }; /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSInteger, ARTRealtimeHistoryError) { ARTRealtimeHistoryErrorNotAttached = ARTDataQueryErrorTimestampRange + 1 }; /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSInteger, ARTCustomRequestError) { ARTCustomRequestErrorInvalidMethod = 1, ARTCustomRequestErrorInvalidBody = 2, @@ -221,6 +230,7 @@ NSString *generateNonce(void); /** * Contains `ARTRealtimeConnectionState` change information emitted by the `ARTConnection` object. */ +NS_SWIFT_SENDABLE @interface ARTConnectionStateChange : NSObject /// :nodoc: @@ -264,6 +274,7 @@ NSString *generateNonce(void); /** * Contains state change information emitted by an `ARTRealtimeChannel` object. */ +NS_SWIFT_SENDABLE @interface ARTChannelStateChange : NSObject /// :nodoc: @@ -309,6 +320,7 @@ NSString *generateNonce(void); /** * Contains the metrics associated with a `ARTRestChannel` or `ARTRealtimeChannel`, such as the number of publishers, subscribers and connections it has. */ +NS_SWIFT_SENDABLE @interface ARTChannelMetrics : NSObject /** @@ -354,6 +366,7 @@ NSString *generateNonce(void); /** * Contains the metrics of a `ARTRestChannel` or `ARTRealtimeChannel` object. */ +NS_SWIFT_SENDABLE @interface ARTChannelOccupancy : NSObject /** @@ -369,6 +382,7 @@ NSString *generateNonce(void); /** * Contains the status of a `ARTRestChannel` or `ARTRealtimeChannel` object such as whether it is active and its `ARTChannelOccupancy`. */ +NS_SWIFT_SENDABLE @interface ARTChannelStatus : NSObject /** @@ -389,6 +403,7 @@ NSString *generateNonce(void); /** * Contains the details of a `ARTRestChannel` or `ARTRealtimeChannel` object such as its ID and `ARTChannelStatus`. */ +NS_SWIFT_SENDABLE @interface ARTChannelDetails : NSObject /** From 401dd03d23bd0835d6b4f63b7c595af8d9ee9116 Mon Sep 17 00:00:00 2001 From: Marat Al Date: Sat, 24 Aug 2024 20:46:00 +0200 Subject: [PATCH 2/7] Removed NS_SWIFT_SENDABLE in all types except those who has its own `queue` and enums (they transformed into swift enums which are sendable). --- Source/include/Ably/ARTAuthDetails.h | 1 - Source/include/Ably/ARTAuthOptions.h | 1 - Source/include/Ably/ARTChannelOptions.h | 1 - Source/include/Ably/ARTClientOptions.h | 1 - Source/include/Ably/ARTConnectionDetails.h | 1 - Source/include/Ably/ARTDataQuery.h | 2 -- Source/include/Ably/ARTDeviceDetails.h | 1 - Source/include/Ably/ARTDeviceIdentityTokenDetails.h | 1 - Source/include/Ably/ARTDevicePushDetails.h | 1 - Source/include/Ably/ARTMessage.h | 1 - Source/include/Ably/ARTPresence.h | 1 - Source/include/Ably/ARTPresenceMessage.h | 1 - Source/include/Ably/ARTPushChannelSubscription.h | 1 - Source/include/Ably/ARTRealtimeChannelOptions.h | 1 - Source/include/Ably/ARTRealtimePresence.h | 1 - Source/include/Ably/ARTRestPresence.h | 1 - Source/include/Ably/ARTStats.h | 9 --------- Source/include/Ably/ARTStatus.h | 2 -- Source/include/Ably/ARTTokenDetails.h | 1 - Source/include/Ably/ARTTokenParams.h | 1 - Source/include/Ably/ARTTokenRequest.h | 1 - Source/include/Ably/ARTTypes.h | 6 ------ 22 files changed, 37 deletions(-) diff --git a/Source/include/Ably/ARTAuthDetails.h b/Source/include/Ably/ARTAuthDetails.h index 6886334ad..46ee9d7df 100644 --- a/Source/include/Ably/ARTAuthDetails.h +++ b/Source/include/Ably/ARTAuthDetails.h @@ -5,7 +5,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the token string used to authenticate a client with Ably. */ -NS_SWIFT_SENDABLE @interface ARTAuthDetails : NSObject /** diff --git a/Source/include/Ably/ARTAuthOptions.h b/Source/include/Ably/ARTAuthOptions.h index 3461e9d2e..511de7fb2 100644 --- a/Source/include/Ably/ARTAuthOptions.h +++ b/Source/include/Ably/ARTAuthOptions.h @@ -18,7 +18,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes authentication-specific properties in authentication requests to Ably. Properties set using `ARTAuthOptions` are used instead of the default values set when the client library is instantiated, as opposed to being merged with them. */ -NS_SWIFT_SENDABLE @interface ARTAuthOptions : NSObject /** diff --git a/Source/include/Ably/ARTChannelOptions.h b/Source/include/Ably/ARTChannelOptions.h index a66b64d7b..f7028d517 100644 --- a/Source/include/Ably/ARTChannelOptions.h +++ b/Source/include/Ably/ARTChannelOptions.h @@ -8,7 +8,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes additional properties to an `ARTRestChannel` object, such as encryption. */ -NS_SWIFT_SENDABLE @interface ARTChannelOptions : NSObject /** diff --git a/Source/include/Ably/ARTClientOptions.h b/Source/include/Ably/ARTClientOptions.h index 59a4e6749..572983a6c 100644 --- a/Source/include/Ably/ARTClientOptions.h +++ b/Source/include/Ably/ARTClientOptions.h @@ -12,7 +12,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes additional client-specific properties to the REST `-[ARTRestProtocol initWithOptions:]` or the Realtime `-[ARTRealtimeProtocol initWithOptions:]`. */ -NS_SWIFT_SENDABLE @interface ARTClientOptions : ARTAuthOptions /** diff --git a/Source/include/Ably/ARTConnectionDetails.h b/Source/include/Ably/ARTConnectionDetails.h index 61b798e30..7121ebd60 100644 --- a/Source/include/Ably/ARTConnectionDetails.h +++ b/Source/include/Ably/ARTConnectionDetails.h @@ -5,7 +5,6 @@ /** * Contains any constraints a client should adhere to and provides additional metadata about a `ARTConnection`, such as if a request to `-[ARTChannelProtocol publish:callback:]` a message that exceeds the maximum message size should be rejected immediately without communicating with Ably. */ -NS_SWIFT_SENDABLE @interface ARTConnectionDetails : NSObject NS_ASSUME_NONNULL_BEGIN diff --git a/Source/include/Ably/ARTDataQuery.h b/Source/include/Ably/ARTDataQuery.h index 78034fc83..829d994d7 100755 --- a/Source/include/Ably/ARTDataQuery.h +++ b/Source/include/Ably/ARTDataQuery.h @@ -14,7 +14,6 @@ typedef NS_ENUM(NSUInteger, ARTQueryDirection) { /** This object is used for providing parameters into methods with paginated results. */ -NS_SWIFT_SENDABLE @interface ARTDataQuery : NSObject /** @@ -42,7 +41,6 @@ NS_SWIFT_SENDABLE /** This object is used for providing parameters into `ARTRealtimePresence`'s methods with paginated results. */ -NS_SWIFT_SENDABLE @interface ARTRealtimeHistoryQuery : ARTDataQuery /** diff --git a/Source/include/Ably/ARTDeviceDetails.h b/Source/include/Ably/ARTDeviceDetails.h index 798d43252..b996fc99c 100644 --- a/Source/include/Ably/ARTDeviceDetails.h +++ b/Source/include/Ably/ARTDeviceDetails.h @@ -8,7 +8,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the properties of a device registered for push notifications. */ -NS_SWIFT_SENDABLE @interface ARTDeviceDetails : NSObject /** diff --git a/Source/include/Ably/ARTDeviceIdentityTokenDetails.h b/Source/include/Ably/ARTDeviceIdentityTokenDetails.h index 00ea3b6bf..5e2463dd3 100644 --- a/Source/include/Ably/ARTDeviceIdentityTokenDetails.h +++ b/Source/include/Ably/ARTDeviceIdentityTokenDetails.h @@ -5,7 +5,6 @@ NS_ASSUME_NONNULL_BEGIN /** * An object representing a unique device identity token used to communicate with APNS. */ -NS_SWIFT_SENDABLE @interface ARTDeviceIdentityTokenDetails : NSObject /** diff --git a/Source/include/Ably/ARTDevicePushDetails.h b/Source/include/Ably/ARTDevicePushDetails.h index 0b2297f57..3822cd595 100644 --- a/Source/include/Ably/ARTDevicePushDetails.h +++ b/Source/include/Ably/ARTDevicePushDetails.h @@ -7,7 +7,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the details of the push registration of a device. */ -NS_SWIFT_SENDABLE @interface ARTDevicePushDetails : NSObject /** diff --git a/Source/include/Ably/ARTMessage.h b/Source/include/Ably/ARTMessage.h index 7c05338d8..88d145170 100644 --- a/Source/include/Ably/ARTMessage.h +++ b/Source/include/Ably/ARTMessage.h @@ -9,7 +9,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains an individual message that is sent to, or received from, Ably. */ -NS_SWIFT_SENDABLE @interface ARTMessage : ARTBaseMessage /// The event name, if available diff --git a/Source/include/Ably/ARTPresence.h b/Source/include/Ably/ARTPresence.h index 8b3b4c88d..e3589105d 100644 --- a/Source/include/Ably/ARTPresence.h +++ b/Source/include/Ably/ARTPresence.h @@ -7,7 +7,6 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: -NS_SWIFT_SENDABLE @interface ARTPresence : NSObject - (void)history:(ARTPaginatedPresenceCallback)callback; diff --git a/Source/include/Ably/ARTPresenceMessage.h b/Source/include/Ably/ARTPresenceMessage.h index c730c6667..c5bf7bd9a 100644 --- a/Source/include/Ably/ARTPresenceMessage.h +++ b/Source/include/Ably/ARTPresenceMessage.h @@ -36,7 +36,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains an individual presence update sent to, or received from, Ably. */ -NS_SWIFT_SENDABLE @interface ARTPresenceMessage : ARTBaseMessage /** diff --git a/Source/include/Ably/ARTPushChannelSubscription.h b/Source/include/Ably/ARTPushChannelSubscription.h index 9c0f06273..eb89e72a2 100644 --- a/Source/include/Ably/ARTPushChannelSubscription.h +++ b/Source/include/Ably/ARTPushChannelSubscription.h @@ -5,7 +5,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the subscriptions of a device, or a group of devices sharing the same `clientId`, has to a channel in order to receive push notifications. */ -NS_SWIFT_SENDABLE @interface ARTPushChannelSubscription : NSObject /** diff --git a/Source/include/Ably/ARTRealtimeChannelOptions.h b/Source/include/Ably/ARTRealtimeChannelOptions.h index af43dc8b6..1bc622cd1 100644 --- a/Source/include/Ably/ARTRealtimeChannelOptions.h +++ b/Source/include/Ably/ARTRealtimeChannelOptions.h @@ -30,7 +30,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes additional properties to an `ARTRealtimeChannel` object, such as encryption, an `ARTChannelMode` and channel parameters. */ -NS_SWIFT_SENDABLE @interface ARTRealtimeChannelOptions : ARTChannelOptions /** diff --git a/Source/include/Ably/ARTRealtimePresence.h b/Source/include/Ably/ARTRealtimePresence.h index 003916b2b..3bb3629a6 100644 --- a/Source/include/Ably/ARTRealtimePresence.h +++ b/Source/include/Ably/ARTRealtimePresence.h @@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN /** This object is used for providing parameters into `ARTRealtimePresence`'s methods with paginated results. */ -NS_SWIFT_SENDABLE @interface ARTRealtimePresenceQuery : ARTPresenceQuery /** diff --git a/Source/include/Ably/ARTRestPresence.h b/Source/include/Ably/ARTRestPresence.h index 83abb34c9..f81f66fb9 100644 --- a/Source/include/Ably/ARTRestPresence.h +++ b/Source/include/Ably/ARTRestPresence.h @@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN /** This object is used for providing parameters into `ARTRestPresence`'s methods with paginated results. */ -NS_SWIFT_SENDABLE @interface ARTPresenceQuery : NSObject /** diff --git a/Source/include/Ably/ARTStats.h b/Source/include/Ably/ARTStats.h index d174178bd..1f2c31dc1 100644 --- a/Source/include/Ably/ARTStats.h +++ b/Source/include/Ably/ARTStats.h @@ -30,7 +30,6 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** This object is used for providing parameters into `ARTStats`'s methods with paginated results. */ -NS_SWIFT_SENDABLE @interface ARTStatsQuery : ARTDataQuery /** @@ -43,7 +42,6 @@ NS_SWIFT_SENDABLE /** * Contains the aggregate counts for messages and data transferred. */ -NS_SWIFT_SENDABLE @interface ARTStatsMessageCount : NSObject /** @@ -71,7 +69,6 @@ NS_SWIFT_SENDABLE /** * Contains a breakdown of summary stats data for different (channel vs presence) message types. */ -NS_SWIFT_SENDABLE @interface ARTStatsMessageTypes : NSObject /** @@ -105,7 +102,6 @@ NS_SWIFT_SENDABLE /** * Contains a breakdown of summary stats data for traffic over various transport types. */ -NS_SWIFT_SENDABLE @interface ARTStatsMessageTraffic : NSObject /** @@ -145,7 +141,6 @@ NS_SWIFT_SENDABLE /** * Contains the aggregate data for usage of a resource in a specific scope. */ -NS_SWIFT_SENDABLE @interface ARTStatsResourceCount : NSObject /** @@ -191,7 +186,6 @@ NS_SWIFT_SENDABLE /** * Contains a breakdown of summary stats data for different (`TLS` vs non-`TLS`) connection types. */ -NS_SWIFT_SENDABLE @interface ARTStatsConnectionTypes : NSObject /** @@ -225,7 +219,6 @@ NS_SWIFT_SENDABLE /** * Contains the aggregate counts for requests made. */ -NS_SWIFT_SENDABLE @interface ARTStatsRequestCount : NSObject /** @@ -259,7 +252,6 @@ NS_SWIFT_SENDABLE /** * Details the stats on push notifications. */ -NS_SWIFT_SENDABLE @interface ARTStatsPushCount : NSObject /** @@ -311,7 +303,6 @@ NS_SWIFT_SENDABLE /** * Contains application statistics for a specified time interval and time period. */ -NS_SWIFT_SENDABLE @interface ARTStats : NSObject /// :nodoc: diff --git a/Source/include/Ably/ARTStatus.h b/Source/include/Ably/ARTStatus.h index 60bde777c..0102ba721 100644 --- a/Source/include/Ably/ARTStatus.h +++ b/Source/include/Ably/ARTStatus.h @@ -190,7 +190,6 @@ FOUNDATION_EXPORT NSString *const ARTAblyMessageNoMeansToRenewToken; * * @see For possible `NSError.code` see Ably [error codes](https://github.com/ably/ably-common/blob/main/protocol/errors.json). */ -NS_SWIFT_SENDABLE @interface ARTErrorInfo : NSError /** @@ -259,7 +258,6 @@ NS_SWIFT_SENDABLE * :nodoc: TODO: docstring * An object representing a status of an operation. */ -NS_SWIFT_SENDABLE @interface ARTStatus : NSObject @property (nullable, readonly, nonatomic) ARTErrorInfo *errorInfo; diff --git a/Source/include/Ably/ARTTokenDetails.h b/Source/include/Ably/ARTTokenDetails.h index e8a1220f0..316d6e52c 100644 --- a/Source/include/Ably/ARTTokenDetails.h +++ b/Source/include/Ably/ARTTokenDetails.h @@ -8,7 +8,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains an Ably Token and its associated metadata. */ -NS_SWIFT_SENDABLE @interface ARTTokenDetails : NSObject /** diff --git a/Source/include/Ably/ARTTokenParams.h b/Source/include/Ably/ARTTokenParams.h index 0cdf264dd..a7877268c 100644 --- a/Source/include/Ably/ARTTokenParams.h +++ b/Source/include/Ably/ARTTokenParams.h @@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Defines the properties of an Ably Token. */ -NS_SWIFT_SENDABLE @interface ARTTokenParams : NSObject /** diff --git a/Source/include/Ably/ARTTokenRequest.h b/Source/include/Ably/ARTTokenRequest.h index 4793694b0..853783f87 100644 --- a/Source/include/Ably/ARTTokenRequest.h +++ b/Source/include/Ably/ARTTokenRequest.h @@ -9,7 +9,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the properties of a request for a token to Ably. Tokens are generated using `-[ARTAuthProtocol requestToken:]`. */ -NS_SWIFT_SENDABLE @interface ARTTokenRequest : NSObject /** diff --git a/Source/include/Ably/ARTTypes.h b/Source/include/Ably/ARTTypes.h index 3c40d6dc1..bfc8f0c08 100644 --- a/Source/include/Ably/ARTTypes.h +++ b/Source/include/Ably/ARTTypes.h @@ -230,7 +230,6 @@ NSString *generateNonce(void); /** * Contains `ARTRealtimeConnectionState` change information emitted by the `ARTConnection` object. */ -NS_SWIFT_SENDABLE @interface ARTConnectionStateChange : NSObject /// :nodoc: @@ -274,7 +273,6 @@ NS_SWIFT_SENDABLE /** * Contains state change information emitted by an `ARTRealtimeChannel` object. */ -NS_SWIFT_SENDABLE @interface ARTChannelStateChange : NSObject /// :nodoc: @@ -320,7 +318,6 @@ NS_SWIFT_SENDABLE /** * Contains the metrics associated with a `ARTRestChannel` or `ARTRealtimeChannel`, such as the number of publishers, subscribers and connections it has. */ -NS_SWIFT_SENDABLE @interface ARTChannelMetrics : NSObject /** @@ -366,7 +363,6 @@ NS_SWIFT_SENDABLE /** * Contains the metrics of a `ARTRestChannel` or `ARTRealtimeChannel` object. */ -NS_SWIFT_SENDABLE @interface ARTChannelOccupancy : NSObject /** @@ -382,7 +378,6 @@ NS_SWIFT_SENDABLE /** * Contains the status of a `ARTRestChannel` or `ARTRealtimeChannel` object such as whether it is active and its `ARTChannelOccupancy`. */ -NS_SWIFT_SENDABLE @interface ARTChannelStatus : NSObject /** @@ -403,7 +398,6 @@ NS_SWIFT_SENDABLE /** * Contains the details of a `ARTRestChannel` or `ARTRealtimeChannel` object such as its ID and `ARTChannelStatus`. */ -NS_SWIFT_SENDABLE @interface ARTChannelDetails : NSObject /** From 9048f946b9fb470e8d351e10437695532c429461 Mon Sep 17 00:00:00 2001 From: Marat Al Date: Sun, 25 Aug 2024 11:33:33 +0200 Subject: [PATCH 3/7] Put some sendables back (`ARTConnectionDetails` has only readonly properties and `ARTRestChannels` calls only methods of a sendable object). --- Source/include/Ably/ARTConnectionDetails.h | 1 + Source/include/Ably/ARTRestChannels.h | 1 + 2 files changed, 2 insertions(+) diff --git a/Source/include/Ably/ARTConnectionDetails.h b/Source/include/Ably/ARTConnectionDetails.h index 7121ebd60..61b798e30 100644 --- a/Source/include/Ably/ARTConnectionDetails.h +++ b/Source/include/Ably/ARTConnectionDetails.h @@ -5,6 +5,7 @@ /** * Contains any constraints a client should adhere to and provides additional metadata about a `ARTConnection`, such as if a request to `-[ARTChannelProtocol publish:callback:]` a message that exceeds the maximum message size should be rejected immediately without communicating with Ably. */ +NS_SWIFT_SENDABLE @interface ARTConnectionDetails : NSObject NS_ASSUME_NONNULL_BEGIN diff --git a/Source/include/Ably/ARTRestChannels.h b/Source/include/Ably/ARTRestChannels.h index 3a9bcc13e..b372859d4 100644 --- a/Source/include/Ably/ARTRestChannels.h +++ b/Source/include/Ably/ARTRestChannels.h @@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// :nodoc: +NS_SWIFT_SENDABLE @interface ARTRestChannels : NSObject - (ARTRestChannel *)get:(NSString *)name; From b44dc8769632ff117f6ffb6b6fb8e05daa55f413 Mon Sep 17 00:00:00 2001 From: Marat Al Date: Thu, 29 Aug 2024 12:12:17 +0200 Subject: [PATCH 4/7] Marked all properties of local device (`ARTLocalDevice` + `ARTDeviceDetails`) as `readonly`. Redeclared them as `readwrite` in a private interface. --- Ably.xcodeproj/project.pbxproj | 8 ++++++++ Source/ARTAuth.m | 1 + Source/ARTDeviceDetails.m | 1 + Source/ARTJsonLikeEncoder.m | 1 + Source/ARTLocalDevice.m | 1 + Source/Ably.modulemap | 1 + .../Ably/ARTDeviceDetails+Private.h | 19 +++++++++++++++++++ .../Ably/ARTLocalDevice+Private.h | 1 + Source/include/Ably/ARTDeviceDetails.h | 12 ++++++------ Source/include/Ably/ARTLocalDevice.h | 2 +- 10 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index 83b9d451d..35fd75dd4 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -290,6 +290,9 @@ 8412FDFE2661AC7B001FE9E6 /* Nimble.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */; }; 8412FDFF2661AC7B001FE9E6 /* Nimble.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */; }; 8412FE002661AC7B001FE9E6 /* Nimble.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */; }; + 844B9CCF2C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 844B9CD02C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 844B9CD12C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 848ED97326E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; }; 848ED97426E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; }; 848ED97526E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; }; @@ -1233,6 +1236,7 @@ 8412FDE12661AC37001FE9E6 /* AblyDeltaCodec.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = AblyDeltaCodec.xcframework; path = Carthage/Build/AblyDeltaCodec.xcframework; sourceTree = ""; }; 8412FDE32661AC37001FE9E6 /* msgpack.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = msgpack.xcframework; path = Carthage/Build/msgpack.xcframework; sourceTree = ""; }; 8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Nimble.xcframework; path = Carthage/Build/Nimble.xcframework; sourceTree = ""; }; + 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ARTDeviceDetails+Private.h"; path = "PrivateHeaders/Ably/ARTDeviceDetails+Private.h"; sourceTree = ""; }; 848ED97226E50D0F0087E800 /* ObjcppTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ObjcppTest.mm; sourceTree = ""; }; 850BFB4A1B79323C009D0ADD /* ARTPaginatedResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARTPaginatedResult.h; path = include/Ably/ARTPaginatedResult.h; sourceTree = ""; }; 850BFB4B1B79323C009D0ADD /* ARTPaginatedResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTPaginatedResult.m; sourceTree = ""; }; @@ -2150,6 +2154,7 @@ D785C4271E549E33008FEC05 /* ARTPushChannelSubscription.h */, D785C4281E549E33008FEC05 /* ARTPushChannelSubscription.m */, D7B621921E4A6FE600684474 /* ARTDeviceDetails.h */, + 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */, D7B621931E4A6FE600684474 /* ARTDeviceDetails.m */, D768C6AA1E4B5B0200436011 /* ARTDevicePushDetails.h */, D768C6AB1E4B5B0200436011 /* ARTDevicePushDetails.m */, @@ -2263,6 +2268,7 @@ 2105ED2229E7429E00DE6D67 /* ARTPaginatedResult+Subclass.h in Headers */, D746AE381BBC3201003ECEF8 /* ARTMessage.h in Headers */, D746AE471BBD6FE9003ECEF8 /* ARTQueuedMessage.h in Headers */, + 844B9CCF2C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */, D798556023ECCDAF00946BE2 /* ARTVCDiffDecoder.h in Headers */, EB9C530B1CD7BEB100.8.557 /* ARTJsonLikeEncoder.h in Headers */, D74CBC0E212F076000D090E4 /* ARTConstants.h in Headers */, @@ -2440,6 +2446,7 @@ D710D4C221949B9C008F54AD /* ARTRealtimeTransport.h in Headers */, D710D58121949D28008F54AD /* ARTTokenRequest.h in Headers */, D710D68421949ECE008F54AD /* ARTNSDictionary+ARTDictionaryUtil.h in Headers */, + 844B9CD02C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */, D5BB212F26AAA55C00AA5F3E /* ARTNSMutableURLRequest+ARTUtils.h in Headers */, D710D50821949C18008F54AD /* ARTRealtimePresence+Private.h in Headers */, D710D4A821949ADF008F54AD /* ARTRestPresence.h in Headers */, @@ -2607,6 +2614,7 @@ D710D52A21949C44008F54AD /* ARTPushChannelSubscription.h in Headers */, D710D4BA21949B48008F54AD /* ARTAuth+Private.h in Headers */, D710D4C621949B9D008F54AD /* ARTRealtimeTransport.h in Headers */, + 844B9CD12C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */, D710D5A721949D2A008F54AD /* ARTTokenRequest.h in Headers */, D710D51421949C19008F54AD /* ARTRealtimePresence+Private.h in Headers */, D710D4AE21949AE0008F54AD /* ARTRestPresence.h in Headers */, diff --git a/Source/ARTAuth.m b/Source/ARTAuth.m index 78a254f93..f5ab59e78 100644 --- a/Source/ARTAuth.m +++ b/Source/ARTAuth.m @@ -23,6 +23,7 @@ #import "ARTInternalLog.h" #import "ARTLocalDeviceStorage.h" #import "ARTLocalDevice+Private.h" +#import "ARTDeviceDetails+Private.h" @implementation ARTAuth { ARTQueuedDealloc *_dealloc; diff --git a/Source/ARTDeviceDetails.m b/Source/ARTDeviceDetails.m index 03e640bb3..1be635a91 100644 --- a/Source/ARTDeviceDetails.m +++ b/Source/ARTDeviceDetails.m @@ -1,5 +1,6 @@ #import "ARTDeviceDetails.h" #import "ARTDevicePushDetails.h" +#import "ARTDeviceDetails+Private.h" @implementation ARTDeviceDetails diff --git a/Source/ARTJsonLikeEncoder.m b/Source/ARTJsonLikeEncoder.m index ff5358755..dbe2c4407 100644 --- a/Source/ARTJsonLikeEncoder.m +++ b/Source/ARTJsonLikeEncoder.m @@ -17,6 +17,7 @@ #import "ARTAuthDetails.h" #import "ARTPush.h" #import "ARTDeviceDetails.h" +#import "ARTDeviceDetails+Private.h" #import "ARTDeviceIdentityTokenDetails.h" #import "ARTDevicePushDetails.h" #import "ARTConnectionDetails.h" diff --git a/Source/ARTLocalDevice.m b/Source/ARTLocalDevice.m index 5a73a80ec..581c4d2c0 100644 --- a/Source/ARTLocalDevice.m +++ b/Source/ARTLocalDevice.m @@ -1,4 +1,5 @@ #import "ARTLocalDevice+Private.h" +#import "ARTDeviceDetails+Private.h" #import "ARTDevicePushDetails.h" #import "ARTPush.h" #import "ARTEncoder.h" diff --git a/Source/Ably.modulemap b/Source/Ably.modulemap index 327d34883..55e72ce45 100644 --- a/Source/Ably.modulemap +++ b/Source/Ably.modulemap @@ -43,6 +43,7 @@ framework module Ably { header "ARTFallback+Private.h" header "ARTFallbackHosts.h" header "ARTLocalDevice+Private.h" + header "ARTDeviceDetails+Private.h" header "ARTPush+Private.h" header "ARTPushAdmin+Private.h" header "ARTPushDeviceRegistrations+Private.h" diff --git a/Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h b/Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h new file mode 100644 index 000000000..ea16cb86f --- /dev/null +++ b/Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h @@ -0,0 +1,19 @@ +#import +#import + +@class ARTDevicePushDetails; + +NS_ASSUME_NONNULL_BEGIN + +@interface ARTDeviceDetails () + +@property (nonatomic, readwrite) ARTDeviceId *id; +@property (nullable, nonatomic, readwrite) NSString *clientId; +@property (nonatomic, readwrite) NSString *platform; +@property (nonatomic, readwrite) NSString *formFactor; +@property (nonatomic, readwrite) NSDictionary *metadata; +@property (nonatomic, readwrite) ARTDevicePushDetails *push; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h b/Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h index de9f0925c..271b8ba12 100644 --- a/Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h +++ b/Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h @@ -19,6 +19,7 @@ NSString* ARTAPNSDeviceTokenKeyOfType(NSString * _Nullable tokenType); @interface ARTLocalDevice () @property (nonatomic) id storage; +@property (nullable, nonatomic, readwrite) ARTDeviceSecret *secret; + (instancetype)deviceWithStorage:(id)storage logger:(nullable ARTInternalLog *)logger; - (nullable NSString *)apnsDeviceToken; diff --git a/Source/include/Ably/ARTDeviceDetails.h b/Source/include/Ably/ARTDeviceDetails.h index b996fc99c..192e42417 100644 --- a/Source/include/Ably/ARTDeviceDetails.h +++ b/Source/include/Ably/ARTDeviceDetails.h @@ -13,32 +13,32 @@ NS_ASSUME_NONNULL_BEGIN /** * A unique ID generated by the device. */ -@property (nonatomic) ARTDeviceId *id; +@property (nonatomic, readonly) ARTDeviceId *id; /** * The client ID the device is connected to Ably with. */ -@property (nullable, nonatomic) NSString *clientId; +@property (nullable, nonatomic, readonly) NSString *clientId; /** * The `ARTDevicePlatform` associated with the device. Describes the platform the device uses, such as `android` or `ios`. */ -@property (nonatomic) NSString *platform; +@property (nonatomic, readonly) NSString *platform; /** * The `ARTDeviceFormFactor` object associated with the device. Describes the type of the device, such as `phone` or `tablet`. */ -@property (nonatomic) NSString *formFactor; +@property (nonatomic, readonly) NSString *formFactor; /** * A JSON object of key-value pairs that contains metadata for the device. */ -@property (nonatomic) NSDictionary *metadata; +@property (nonatomic, readonly) NSDictionary *metadata; /** * The `ARTDevicePushDetails` object associated with the device. Describes the details of the push registration of the device. */ -@property (nonatomic) ARTDevicePushDetails *push; +@property (nonatomic, readonly) ARTDevicePushDetails *push; /// :nodoc: - (instancetype)init; diff --git a/Source/include/Ably/ARTLocalDevice.h b/Source/include/Ably/ARTLocalDevice.h index a5d11ab7e..36247f6c5 100644 --- a/Source/include/Ably/ARTLocalDevice.h +++ b/Source/include/Ably/ARTLocalDevice.h @@ -19,7 +19,7 @@ NS_SWIFT_SENDABLE /** * A unique device secret generated by the Ably SDK. */ -@property (nullable, nonatomic) ARTDeviceSecret *secret; +@property (nullable, nonatomic, readonly) ARTDeviceSecret *secret; /// :nodoc: - (instancetype)init NS_UNAVAILABLE; From 58ccb88a5b61f3fb160a863487fa00b3d078fd79 Mon Sep 17 00:00:00 2001 From: Marat Al Date: Fri, 30 Aug 2024 15:35:26 +0200 Subject: [PATCH 5/7] Added `frozen` property to `ARTChannelOptions` to avoid mutation of options after channel initialization. --- Ably.xcodeproj/project.pbxproj | 8 ++++ Source/ARTChannel.m | 3 +- Source/ARTChannelOptions.m | 19 +++++++- Source/ARTRealtimeChannelOptions.m | 32 ++++++++++++- Source/Ably.modulemap | 1 + .../Ably/ARTChannelOptions+Private.h | 8 ++++ Test/Test Utilities/NSObject+TestSuite.h | 2 + Test/Test Utilities/NSObject+TestSuite.m | 10 +++++ Test/Tests/RealtimeClientChannelTests.swift | 45 ++++++++++++++++++- 9 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index 35fd75dd4..2aa2e1e95 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -284,6 +284,9 @@ 80E519C72BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; 80E519C82BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; 80E519C92BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; + 84039A4C2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 84039A4D2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 84039A4E2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 841134782722205400CFA837 /* ARTArchiveTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 841134772722205400CFA837 /* ARTArchiveTests.m */; }; 8412FDE72661AC37001FE9E6 /* AblyDeltaCodec.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDE12661AC37001FE9E6 /* AblyDeltaCodec.xcframework */; }; 8412FDED2661AC37001FE9E6 /* msgpack.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDE32661AC37001FE9E6 /* msgpack.xcframework */; }; @@ -1232,6 +1235,7 @@ 560579D824AF1BA900A4D03D /* ARTDefaultTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ARTDefaultTests.swift; sourceTree = ""; }; 56190953238C3D3200A862A6 /* CryptoTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CryptoTest.m; sourceTree = ""; }; 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ARTChannelOptions+Private.h"; path = "PrivateHeaders/Ably/ARTChannelOptions+Private.h"; sourceTree = ""; }; 841134772722205400CFA837 /* ARTArchiveTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTArchiveTests.m; sourceTree = ""; }; 8412FDE12661AC37001FE9E6 /* AblyDeltaCodec.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = AblyDeltaCodec.xcframework; path = Carthage/Build/AblyDeltaCodec.xcframework; sourceTree = ""; }; 8412FDE32661AC37001FE9E6 /* msgpack.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = msgpack.xcframework; path = Carthage/Build/msgpack.xcframework; sourceTree = ""; }; @@ -2003,6 +2007,7 @@ D746AE551BBD8622003ECEF8 /* ARTChannels+Private.h */, D746AE521BBD85C5003ECEF8 /* ARTChannels.m */, D746AE4D1BBD84E7003ECEF8 /* ARTChannelOptions.h */, + 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */, D746AE4E1BBD84E7003ECEF8 /* ARTChannelOptions.m */, 96E408411A38939E00087F77 /* ARTProtocolMessage.h */, D77394021C6F6FFE00F5478F /* ARTProtocolMessage+Private.h */, @@ -2368,6 +2373,7 @@ D7D8F82B1BC2C706009718F2 /* ARTTokenRequest.h in Headers */, 2147F02D29E583AD0071CB94 /* ARTInternalLogCore.h in Headers */, D5BB211126AA993E00AA5F3E /* ARTNSURL+ARTUtils.h in Headers */, + 84039A4C2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */, EB1AE0CC1C5C1EB200D62250 /* ARTEventEmitter+Private.h in Headers */, 215F75F82922B1DB009E0E76 /* ARTClientInformation.h in Headers */, D7DF738A1EA645300013CD36 /* ARTLocalDeviceStorage.h in Headers */, @@ -2471,6 +2477,7 @@ 211A610429DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */, D7D06F1026330E2800DEBDAD /* ARTHttp+Private.h in Headers */, 210F67A329E9D718007B9345 /* ARTRealtimeTransportFactory.h in Headers */, + 84039A4D2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */, EB1B541A22FB1D7F006A59AC /* ARTPushChannelSubscriptions+Private.h in Headers */, D710D48921949A85008F54AD /* ARTConstants.h in Headers */, D710D60921949DA9008F54AD /* ARTURLSessionServerTrust.h in Headers */, @@ -2639,6 +2646,7 @@ 211A610529DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */, D7D06F1126330E2900DEBDAD /* ARTHttp+Private.h in Headers */, 210F67A429E9D718007B9345 /* ARTRealtimeTransportFactory.h in Headers */, + 84039A4E2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */, EB1B541B22FB1D7F006A59AC /* ARTPushChannelSubscriptions+Private.h in Headers */, D710D48B21949A86008F54AD /* ARTConstants.h in Headers */, D710D60B21949DAA008F54AD /* ARTURLSessionServerTrust.h in Headers */, diff --git a/Source/ARTChannel.m b/Source/ARTChannel.m index d29fc40c3..225b71fc4 100644 --- a/Source/ARTChannel.m +++ b/Source/ARTChannel.m @@ -1,6 +1,6 @@ #import "ARTChannel+Private.h" #import "ARTChannel+Subclass.h" - +#import "ARTChannelOptions+Private.h" #import "ARTDataEncoder.h" #import "ARTMessage.h" #import "ARTChannelOptions.h" @@ -23,6 +23,7 @@ - (instancetype)initWithName:(NSString *)name andOptions:(ARTChannelOptions *)op _logger = logger; _queue = rest.queue; _options = options; + _options.frozen = YES; NSError *error = nil; _dataEncoder = [[ARTDataEncoder alloc] initWithCipherParams:_options.cipher logger:_logger error:&error]; if (error != nil) { diff --git a/Source/ARTChannelOptions.m b/Source/ARTChannelOptions.m index e18e22401..5da50e890 100644 --- a/Source/ARTChannelOptions.m +++ b/Source/ARTChannelOptions.m @@ -1,8 +1,10 @@ #import "ARTChannelOptions.h" - +#import "ARTChannelOptions+Private.h" #import "ARTEncoder.h" -@implementation ARTChannelOptions +@implementation ARTChannelOptions { + ARTCipherParams *_cipher; +} - (instancetype)initWithCipher:(id)cipherParams { if (self = [super init]) { @@ -15,4 +17,17 @@ - (instancetype)initWithCipherKey:(id)key { return [self initWithCipher:@{@"key": key}]; } +- (ARTCipherParams *)cipher { + return _cipher; +} + +- (void)setCipher:(ARTCipherParams *)cipher { + if (self.isFrozen) { + @throw [NSException exceptionWithName:NSObjectInaccessibleException + reason:[NSString stringWithFormat:@"%@: You can't change options after you've passed it to receiver.", self.class] + userInfo:nil]; + } + _cipher = cipher; +} + @end diff --git a/Source/ARTRealtimeChannelOptions.m b/Source/ARTRealtimeChannelOptions.m index 3f978cef8..a65606e96 100644 --- a/Source/ARTRealtimeChannelOptions.m +++ b/Source/ARTRealtimeChannelOptions.m @@ -1,5 +1,35 @@ #import "ARTRealtimeChannelOptions.h" +#import "ARTChannelOptions+Private.h" -@implementation ARTRealtimeChannelOptions +@implementation ARTRealtimeChannelOptions { + NSStringDictionary *_params; + ARTChannelMode _modes; +} + +- (NSStringDictionary *)params { + return _params; +} + +- (void)setParams:(NSStringDictionary *)params { + if (self.isFrozen) { + @throw [NSException exceptionWithName:NSObjectInaccessibleException + reason:[NSString stringWithFormat:@"%@: You can't change options after you've passed it to receiver.", self.class] + userInfo:nil]; + } + _params = params; +} + +- (ARTChannelMode)modes { + return _modes; +} + +- (void)setModes:(ARTChannelMode)modes { + if (self.isFrozen) { + @throw [NSException exceptionWithName:NSObjectInaccessibleException + reason:[NSString stringWithFormat:@"%@: You can't change options after you've passed it to receiver.", self.class] + userInfo:nil]; + } + _modes = modes; +} @end diff --git a/Source/Ably.modulemap b/Source/Ably.modulemap index 55e72ce45..f97919cb9 100644 --- a/Source/Ably.modulemap +++ b/Source/Ably.modulemap @@ -36,6 +36,7 @@ framework module Ably { header "ARTWebSocketTransport+Private.h" header "ARTWebSocket.h" header "ARTClientOptions+Private.h" + header "ARTChannelOptions+Private.h" header "ARTCrypto+Private.h" header "ARTLog+Private.h" header "ARTRealtimePresence+Private.h" diff --git a/Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h b/Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h new file mode 100644 index 000000000..5bb3101b5 --- /dev/null +++ b/Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h @@ -0,0 +1,8 @@ +#import +#import + +@interface ARTChannelOptions () + +@property (nonatomic, getter=isFrozen) BOOL frozen; + +@end diff --git a/Test/Test Utilities/NSObject+TestSuite.h b/Test/Test Utilities/NSObject+TestSuite.h index cc61f6341..58c46e680 100644 --- a/Test/Test Utilities/NSObject+TestSuite.h +++ b/Test/Test Utilities/NSObject+TestSuite.h @@ -30,3 +30,5 @@ NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END @end + +NSException * _Nullable tryInObjC(void(NS_NOESCAPE^_Nonnull tryBlock)(void)); diff --git a/Test/Test Utilities/NSObject+TestSuite.m b/Test/Test Utilities/NSObject+TestSuite.m index dfabc8c3e..0267dbc2a 100644 --- a/Test/Test Utilities/NSObject+TestSuite.m +++ b/Test/Test Utilities/NSObject+TestSuite.m @@ -48,3 +48,13 @@ @implementation NSObject (TestSuite) } @end + +NSException * _Nullable tryInObjC(void(NS_NOESCAPE^_Nonnull tryBlock)(void)) { + @try { + tryBlock(); + } + @catch (NSException *exception) { + return exception; + } + return nil; +} diff --git a/Test/Tests/RealtimeClientChannelTests.swift b/Test/Tests/RealtimeClientChannelTests.swift index 752278d35..b29873c91 100644 --- a/Test/Tests/RealtimeClientChannelTests.swift +++ b/Test/Tests/RealtimeClientChannelTests.swift @@ -1687,10 +1687,12 @@ class RealtimeClientChannelTests: XCTestCase { } } - channelOptions.modes = [.subscribe] + let channelOptions2 = ARTRealtimeChannelOptions() + channelOptions2.params = ["rewind": "1"] + channelOptions2.modes = [.subscribe] let client2 = ARTRealtime(options: options) defer { client2.dispose(); client2.close() } - let channelWithoutAttachResume = client2.channels.get(channelName, options: channelOptions) + let channelWithoutAttachResume = client2.channels.get(channelName, options: channelOptions2) waitUntil(timeout: testTimeout) { done in channelWithoutAttachResume.subscribe { message in XCTAssertEqual(message.name, "test") @@ -4785,4 +4787,43 @@ class RealtimeClientChannelTests: XCTestCase { } } } + + // TB1 + func test__140__ChannelOptions__options_provided_when_instantiating_a_channel_should_be_frozen() throws { + let test = Test() + let options = try AblyTests.commonAppSetup(for: test) + options.autoConnect = false + let realtime = AblyTests.newRealtime(options).client + defer { realtime.dispose(); realtime.close() } + + let (keyData, ivData, _) = AblyTests.loadCryptoTestData("crypto-data-128") + let cipherParams = ARTCipherParams(algorithm: "aes", key: keyData as ARTCipherKeyCompatible, iv: ivData) + + let channelOptions = ARTRealtimeChannelOptions() + + // not frozen + channelOptions.cipher = cipherParams + channelOptions.modes = [.publish] + channelOptions.params = ["rewind": "1"] + + _ = realtime.channels.get(test.uniqueChannelName(), options: channelOptions) + + let exception1 = tryInObjC { + channelOptions.cipher = cipherParams // frozen + } + XCTAssertNotNil(exception1) + XCTAssertEqual(exception1!.name, NSExceptionName.objectInaccessibleException) + + let exception2 = tryInObjC { + channelOptions.modes = [.publish] // frozen + } + XCTAssertNotNil(exception2) + XCTAssertEqual(exception2!.name, NSExceptionName.objectInaccessibleException) + + let exception3 = tryInObjC { + channelOptions.params = ["rewind": "1"] // frozen + } + XCTAssertNotNil(exception3) + XCTAssertEqual(exception3!.name, NSExceptionName.objectInaccessibleException) + } } From daacb62f29917b6d4153fcdbd928df7828037377 Mon Sep 17 00:00:00 2001 From: Marat Al Date: Tue, 3 Sep 2024 17:17:15 +0200 Subject: [PATCH 6/7] Added forgotten `NS_SWIFT_SENDABLE` for `ARTRealtimeChannels`. --- Source/include/Ably/ARTRealtimeChannels.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/include/Ably/ARTRealtimeChannels.h b/Source/include/Ably/ARTRealtimeChannels.h index e927c3595..2ececfc30 100644 --- a/Source/include/Ably/ARTRealtimeChannels.h +++ b/Source/include/Ably/ARTRealtimeChannels.h @@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// :nodoc: +NS_SWIFT_SENDABLE @interface ARTRealtimeChannels : NSObject - (ARTRealtimeChannel *)get:(NSString *)name; From dc8f1684cf601b46a877dd8020542d1700f9418b Mon Sep 17 00:00:00 2001 From: Marat Al Date: Tue, 3 Sep 2024 17:18:08 +0200 Subject: [PATCH 7/7] Made `ARTDevicePushDetails` properties readonly and made both `ARTDeviceDetails` and `ARTDevicePushDetails` sendable. --- Ably.xcodeproj/project.pbxproj | 8 ++++++++ Source/ARTDevicePushDetails.m | 3 ++- Source/ARTJsonLikeEncoder.m | 1 + Source/Ably.modulemap | 1 + .../Ably/ARTDevicePushDetails+Private.h | 15 +++++++++++++++ Source/include/Ably/ARTDeviceDetails.h | 1 + Source/include/Ably/ARTDevicePushDetails.h | 7 ++++--- 7 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index 2aa2e1e95..d0aec78ec 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -287,6 +287,9 @@ 84039A4C2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 84039A4D2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 84039A4E2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 840FCE532C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 840FCE542C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 840FCE552C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 841134782722205400CFA837 /* ARTArchiveTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 841134772722205400CFA837 /* ARTArchiveTests.m */; }; 8412FDE72661AC37001FE9E6 /* AblyDeltaCodec.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDE12661AC37001FE9E6 /* AblyDeltaCodec.xcframework */; }; 8412FDED2661AC37001FE9E6 /* msgpack.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDE32661AC37001FE9E6 /* msgpack.xcframework */; }; @@ -1236,6 +1239,7 @@ 56190953238C3D3200A862A6 /* CryptoTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CryptoTest.m; sourceTree = ""; }; 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ARTChannelOptions+Private.h"; path = "PrivateHeaders/Ably/ARTChannelOptions+Private.h"; sourceTree = ""; }; + 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ARTDevicePushDetails+Private.h"; path = "PrivateHeaders/Ably/ARTDevicePushDetails+Private.h"; sourceTree = ""; }; 841134772722205400CFA837 /* ARTArchiveTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTArchiveTests.m; sourceTree = ""; }; 8412FDE12661AC37001FE9E6 /* AblyDeltaCodec.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = AblyDeltaCodec.xcframework; path = Carthage/Build/AblyDeltaCodec.xcframework; sourceTree = ""; }; 8412FDE32661AC37001FE9E6 /* msgpack.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = msgpack.xcframework; path = Carthage/Build/msgpack.xcframework; sourceTree = ""; }; @@ -2162,6 +2166,7 @@ 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */, D7B621931E4A6FE600684474 /* ARTDeviceDetails.m */, D768C6AA1E4B5B0200436011 /* ARTDevicePushDetails.h */, + 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */, D768C6AB1E4B5B0200436011 /* ARTDevicePushDetails.m */, D777EEDE206285CF002EBA03 /* ARTDeviceIdentityTokenDetails.h */, 2124B7A229DB153500AD8361 /* ARTDeviceIdentityTokenDetails+Private.h */, @@ -2243,6 +2248,7 @@ EB2D84F71CD75CCE00F23CDA /* ARTReachability.h in Headers */, D73B655523EF2B2900D459A6 /* ARTDeltaCodec.h in Headers */, 1C1EC3FA1AE26A8B00AAADD7 /* ARTStatus.h in Headers */, + 840FCE532C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */, D70EAAED1BC3376200CD8B9E /* ARTRestChannel.h in Headers */, 96BF61581A35B52C004CF2B3 /* ARTHttp.h in Headers */, 96BF61641A35CDE1004CF2B3 /* ARTBaseMessage.h in Headers */, @@ -2484,6 +2490,7 @@ D710D51621949C42008F54AD /* ARTPush.h in Headers */, D737F827263AF4CE0064FA05 /* ARTFallbackHosts.h in Headers */, D710D4D521949BF9008F54AD /* ARTRealtimeChannel.h in Headers */, + 840FCE542C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */, 21276CBB29EF323100107B5F /* ARTContinuousClock.h in Headers */, D710D51721949C42008F54AD /* ARTPushChannel.h in Headers */, D710D51E21949C42008F54AD /* ARTLocalDeviceStorage.h in Headers */, @@ -2653,6 +2660,7 @@ D710D52821949C44008F54AD /* ARTPush.h in Headers */, D737F828263AF4CE0064FA05 /* ARTFallbackHosts.h in Headers */, D710D4E521949BFB008F54AD /* ARTRealtimeChannel.h in Headers */, + 840FCE552C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */, 21276CBC29EF323100107B5F /* ARTContinuousClock.h in Headers */, D710D52921949C44008F54AD /* ARTPushChannel.h in Headers */, D710D53021949C44008F54AD /* ARTLocalDeviceStorage.h in Headers */, diff --git a/Source/ARTDevicePushDetails.m b/Source/ARTDevicePushDetails.m index 5cfa7e7e0..3fc3ed571 100644 --- a/Source/ARTDevicePushDetails.m +++ b/Source/ARTDevicePushDetails.m @@ -1,5 +1,6 @@ -#import "ARTDevicePushDetails.h" #import "ARTPush.h" +#import "ARTDevicePushDetails.h" +#import "ARTDevicePushDetails+Private.h" @implementation ARTDevicePushDetails diff --git a/Source/ARTJsonLikeEncoder.m b/Source/ARTJsonLikeEncoder.m index dbe2c4407..d63c08439 100644 --- a/Source/ARTJsonLikeEncoder.m +++ b/Source/ARTJsonLikeEncoder.m @@ -20,6 +20,7 @@ #import "ARTDeviceDetails+Private.h" #import "ARTDeviceIdentityTokenDetails.h" #import "ARTDevicePushDetails.h" +#import "ARTDevicePushDetails+Private.h" #import "ARTConnectionDetails.h" #import "ARTRest+Private.h" #import "ARTJsonEncoder.h" diff --git a/Source/Ably.modulemap b/Source/Ably.modulemap index f97919cb9..fb003b9ad 100644 --- a/Source/Ably.modulemap +++ b/Source/Ably.modulemap @@ -45,6 +45,7 @@ framework module Ably { header "ARTFallbackHosts.h" header "ARTLocalDevice+Private.h" header "ARTDeviceDetails+Private.h" + header "ARTDevicePushDetails+Private.h" header "ARTPush+Private.h" header "ARTPushAdmin+Private.h" header "ARTPushDeviceRegistrations+Private.h" diff --git a/Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h b/Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h new file mode 100644 index 000000000..6d52d8c3c --- /dev/null +++ b/Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h @@ -0,0 +1,15 @@ +#import + +@class ARTErrorInfo; + +NS_ASSUME_NONNULL_BEGIN + +@interface ARTDevicePushDetails () + +@property (nonatomic, readwrite) NSMutableDictionary *recipient; +@property (nullable, nonatomic, readwrite) NSString *state; +@property (nullable, nonatomic, readwrite) ARTErrorInfo *errorReason; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/include/Ably/ARTDeviceDetails.h b/Source/include/Ably/ARTDeviceDetails.h index 192e42417..f3832e3f7 100644 --- a/Source/include/Ably/ARTDeviceDetails.h +++ b/Source/include/Ably/ARTDeviceDetails.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the properties of a device registered for push notifications. */ +NS_SWIFT_SENDABLE @interface ARTDeviceDetails : NSObject /** diff --git a/Source/include/Ably/ARTDevicePushDetails.h b/Source/include/Ably/ARTDevicePushDetails.h index 3822cd595..6c3b1c8cc 100644 --- a/Source/include/Ably/ARTDevicePushDetails.h +++ b/Source/include/Ably/ARTDevicePushDetails.h @@ -7,22 +7,23 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the details of the push registration of a device. */ +NS_SWIFT_SENDABLE @interface ARTDevicePushDetails : NSObject /** * A JSON object of key-value pairs that contains of the push transport and address. */ -@property (nonatomic) NSMutableDictionary *recipient; +@property (nonatomic, readonly) NSMutableDictionary *recipient; /** * The current state of the push registration. */ -@property (nullable, nonatomic) NSString *state; +@property (nullable, nonatomic, readonly) NSString *state; /** * An `ARTErrorInfo` object describing the most recent error when the `state` is `Failing` or `Failed`. */ -@property (nullable, nonatomic) ARTErrorInfo *errorReason; +@property (nullable, nonatomic, readonly) ARTErrorInfo *errorReason; /// :nodoc: - (instancetype)init;