From f1b575c3436260dadeb5cd0fe3c059a796decc41 Mon Sep 17 00:00:00 2001 From: jguz-pubnub Date: Tue, 10 Dec 2024 09:38:55 +0100 Subject: [PATCH 1/4] Fix excessive memory usage in the high-volume messages use case --- .../URLSessionConfiguration+PubNub.swift | 2 ++ Sources/PubNub/Models/PubNubFile.swift | 29 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Sources/PubNub/Extensions/URLSessionConfiguration+PubNub.swift b/Sources/PubNub/Extensions/URLSessionConfiguration+PubNub.swift index 69361dd7..0293e43a 100644 --- a/Sources/PubNub/Extensions/URLSessionConfiguration+PubNub.swift +++ b/Sources/PubNub/Extensions/URLSessionConfiguration+PubNub.swift @@ -50,6 +50,8 @@ public extension URLSessionConfiguration { let configuration = URLSessionConfiguration.pubnub configuration.timeoutIntervalForRequest += Constant.minimumSubscribeRequestTimeout configuration.httpMaximumConnectionsPerHost = 1 + configuration.requestCachePolicy = .reloadIgnoringLocalCacheData + configuration.urlCache = nil return configuration } diff --git a/Sources/PubNub/Models/PubNubFile.swift b/Sources/PubNub/Models/PubNubFile.swift index 5569f327..805eda25 100644 --- a/Sources/PubNub/Models/PubNubFile.swift +++ b/Sources/PubNub/Models/PubNubFile.swift @@ -305,6 +305,8 @@ public protocol PubNubFileEvent { var additionalMessage: JSONCodable? { get } /// Meta information for the event var metadata: JSONCodable? { get } + /// A user-provided custom message type + var customMessageType: String? { get set } /// Allows for converting between different `PubNubFileEvent` types init(from other: PubNubFileEvent) throws @@ -339,39 +341,43 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable { public var channelGroup: String? public var publisher: String public var timetoken: Timetoken + public var customMessageType: String? - var concreteFile: PubNubFileBase public var file: PubNubFile { - return concreteFile + concreteFile } - var concreteAdditionalMessage: AnyJSON? public var additionalMessage: JSONCodable? { get { - return concreteAdditionalMessage + concreteAdditionalMessage } set { concreteAdditionalMessage = newValue?.codableValue } } - - var concreteMeta: AnyJSON? + public var metadata: JSONCodable? { get { - return concreteMeta + concreteMeta } set { concreteMeta = newValue?.codableValue } } + var concreteFile: PubNubFileBase + var concreteAdditionalMessage: AnyJSON? + var concreteMeta: AnyJSON? + + public init( file: PubNubFile, channelGroup: String?, publisher: String, timetoken: Timetoken, additionalMessage: JSONCodable?, - metadata: JSONCodable? + metadata: JSONCodable?, + customMessageType: String? = nil ) { concreteFile = PubNubFileBase(from: file) self.channelGroup = channelGroup @@ -379,6 +385,7 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable { self.timetoken = timetoken self.additionalMessage = additionalMessage self.metadata = metadata + self.customMessageType = customMessageType } public init(from other: PubNubFileEvent) throws { @@ -388,7 +395,8 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable { publisher: other.publisher, timetoken: other.timetoken, additionalMessage: other.additionalMessage, - metadata: other.metadata + metadata: other.metadata, + customMessageType: other.customMessageType ) } @@ -414,7 +422,8 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable { publisher: publisher, timetoken: subscription.publishTimetoken.timetoken, additionalMessage: filePayload.additionalDetails, - metadata: subscription.metadata + metadata: subscription.metadata, + customMessageType: subscription.customMessageType ) } From 66f936a4c8b21761851ea3699891636122627c33 Mon Sep 17 00:00:00 2001 From: jguz-pubnub Date: Tue, 10 Dec 2024 10:07:21 +0100 Subject: [PATCH 2/4] SwiftLint --- Sources/PubNub/Models/PubNubFile.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/PubNub/Models/PubNubFile.swift b/Sources/PubNub/Models/PubNubFile.swift index 805eda25..653f7804 100644 --- a/Sources/PubNub/Models/PubNubFile.swift +++ b/Sources/PubNub/Models/PubNubFile.swift @@ -355,7 +355,7 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable { concreteAdditionalMessage = newValue?.codableValue } } - + public var metadata: JSONCodable? { get { concreteMeta @@ -369,7 +369,6 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable { var concreteAdditionalMessage: AnyJSON? var concreteMeta: AnyJSON? - public init( file: PubNubFile, channelGroup: String?, From 2cd62395d0cba184c03fc1cf94642f3f9a026078 Mon Sep 17 00:00:00 2001 From: jguz-pubnub Date: Tue, 10 Dec 2024 10:37:33 +0100 Subject: [PATCH 3/4] KMPFileChangeEvent.swift --- Sources/PubNub/KMP/Wrappers/KMPFileChangeEvent.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/PubNub/KMP/Wrappers/KMPFileChangeEvent.swift b/Sources/PubNub/KMP/Wrappers/KMPFileChangeEvent.swift index 123687d9..d5dd8032 100644 --- a/Sources/PubNub/KMP/Wrappers/KMPFileChangeEvent.swift +++ b/Sources/PubNub/KMP/Wrappers/KMPFileChangeEvent.swift @@ -24,6 +24,7 @@ public class KMPFileChangeEvent: NSObject { @objc public let publisher: String? @objc public let message: KMPAnyJSON? @objc public let metadata: KMPAnyJSON? + @objc public let customMessageType: String? @objc public let subscription: String? @objc public let file: KMPFile @@ -36,6 +37,7 @@ public class KMPFileChangeEvent: NSObject { publisher: fileEvent.publisher, message: fileEvent.additionalMessage?.codableValue, metadata: fileEvent.metadata?.codableValue, + customMessageType: fileEvent.customMessageType, subscription: fileEvent.channelGroup, file: KMPFile( from: fileEvent.file, @@ -51,6 +53,7 @@ public class KMPFileChangeEvent: NSObject { publisher: String?, message: AnyJSON?, metadata: AnyJSON?, + customMessageType: String?, subscription: String?, file: KMPFile ) { @@ -59,6 +62,7 @@ public class KMPFileChangeEvent: NSObject { self.publisher = publisher self.message = if let message = message { KMPAnyJSON(message) } else { nil } self.metadata = if let metadata = metadata { KMPAnyJSON(metadata) } else { nil } + self.customMessageType = customMessageType self.subscription = subscription self.file = file } From 45d33c23c1f3f1706f499da2f42db04de0093380 Mon Sep 17 00:00:00 2001 From: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:54:09 +0000 Subject: [PATCH 4/4] PubNub SDK 8.2.2 release. --- .pubnub.yml | 11 +++++++++-- PubNub.xcodeproj/project.pbxproj | 16 ++++++++-------- PubNubSwift.podspec | 2 +- Sources/PubNub/Helpers/Constants.swift | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index 751d1ceb..2f9dc9e0 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,9 +1,16 @@ --- name: swift scm: github.com/pubnub/swift -version: "8.2.1" +version: "8.2.2" schema: 1 changelog: + - date: 2024-12-11 + version: 8.2.2 + changes: + - type: bug + text: "Fix excessive memory usage in the high-volume messages use case." + - type: bug + text: "Add missing `customMessageType` in `PubNubFileEvent`." - date: 2024-12-09 version: 8.2.1 changes: @@ -624,7 +631,7 @@ sdks: - distribution-type: source distribution-repository: GitHub release package-name: PubNub - location: https://github.com/pubnub/swift/archive/refs/tags/8.2.1.zip + location: https://github.com/pubnub/swift/archive/refs/tags/8.2.2.zip supported-platforms: supported-operating-systems: macOS: diff --git a/PubNub.xcodeproj/project.pbxproj b/PubNub.xcodeproj/project.pbxproj index a4f0d0cb..0deb79bf 100644 --- a/PubNub.xcodeproj/project.pbxproj +++ b/PubNub.xcodeproj/project.pbxproj @@ -3995,7 +3995,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 8.2.1; + MARKETING_VERSION = 8.2.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -4046,7 +4046,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 8.2.1; + MARKETING_VERSION = 8.2.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4154,7 +4154,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 8.2.1; + MARKETING_VERSION = 8.2.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -4207,7 +4207,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 8.2.1; + MARKETING_VERSION = 8.2.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4328,7 +4328,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 8.2.1; + MARKETING_VERSION = 8.2.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -4380,7 +4380,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 8.2.1; + MARKETING_VERSION = 8.2.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4860,7 +4860,7 @@ "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 8.2.1; + MARKETING_VERSION = 8.2.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14"; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -4903,7 +4903,7 @@ "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 8.2.1; + MARKETING_VERSION = 8.2.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14"; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; diff --git a/PubNubSwift.podspec b/PubNubSwift.podspec index 23308a05..8c70511c 100644 --- a/PubNubSwift.podspec +++ b/PubNubSwift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'PubNubSwift' - s.version = '8.2.1' + s.version = '8.2.2' s.homepage = 'https://github.com/pubnub/swift' s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk' s.authors = { 'PubNub, Inc.' => 'support@pubnub.com' } diff --git a/Sources/PubNub/Helpers/Constants.swift b/Sources/PubNub/Helpers/Constants.swift index 42dc2182..1ef03510 100644 --- a/Sources/PubNub/Helpers/Constants.swift +++ b/Sources/PubNub/Helpers/Constants.swift @@ -57,7 +57,7 @@ public enum Constant { static let pubnubSwiftSDKName: String = "PubNubSwift" - static let pubnubSwiftSDKVersion: String = "8.2.1" + static let pubnubSwiftSDKVersion: String = "8.2.2" static let appBundleId: String = { if let info = Bundle.main.infoDictionary,