Skip to content

Commit

Permalink
8.0 migration guide, SwiftLint
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Sep 18, 2024
1 parent 2175a86 commit fdc64fd
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 10 deletions.
16 changes: 16 additions & 0 deletions Documentation/PubNub_8_0_Migration_Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# PubNub 8.0 Migration Guide
PubNub Native Swift SDK v8.0 is the latest major release of the PubNub SDK for iOS, tvOS, macOS and watchOS written in Swift. As a major release, following [Semantic Versioning](https://semver.org/) conventions, 8.0 introduces API-breaking changes.

This guide is meant to ease the transition to the 8.0 version of the SDK. To read the full set of documentation, please head over to our official [docs page](https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk)

## Breaking API Changes
___

### Module name

* The module name has been changed to `PubNubSDK` due to a compiler error that occurs when a public type shares the same name as a module. As a result, you will need to replace `import PubNub` with `import PubNubSDK` in your Swift code. Additionally, ensure that `PubNubSDK` is listed in the `Frameworks, Libraries, and Embedded Content` section under the `General` tab in Xcode.

### `ConnectionStatus`

* The following cases of the `ConnectionStatus` enumeration are no longer supported: `.connecting` and `.reconnecting`.
* This version introduces a new `.subscriptionChanged(channels, groups)` connection status, indicating that the SDK has subscribed to new channels or channel groups. This status is triggered each time the channel or channel group mix changes after the initial connection, and it provides all currently subscribed channels and channel groups. Additionally, you can check your current activity status locally by accessing the `isActive` property on `ConnectionStatus`
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pubnub.subscribe(to: ["my_channel"])

* [Build your first realtime Swift app with PubNub](https://www.pubnub.com/docs/platform/quickstarts/swift)
* [API reference for Swift](https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk)
* [PubNub Swift SDK 3.x Migration Guide](https://github.com/pubnub/swift/blob/master/Documentation/PubNub_3_0_Migration_Guide.md)
* [PubNub Swift SDK 8.x Migration Guide](https://github.com/pubnub/swift/blob/master/Documentation/PubNub_8_0_Migration_Guide.md)

## Support

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SubscriptionListenersContainer {
func removeStatusListener(_ listener: StatusListener) {
statusListenersCache.lockedWrite { $0[listener.uuid] = nil }
}

func removeAllEventListeners() {
eventListenersCache.lockedWrite { $0.removeAll() }
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/PubNub/KMP/KMPPubNub+Listeners.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ extension KMPPubNub {
onFileEvent: { [weak pubnub] in listener.onFile?(KMPFileChangeEvent.from(event: $0, with: pubnub)) },
onAppContext: { listener.onAppContext?(KMPAppContextEventResult.from(event: $0)) }
)

// Establishes an association to infer which Swift listener
// corresponds to which KMP listener
listener.underlying = swiftListener

return swiftListener
}

Expand Down Expand Up @@ -85,11 +85,11 @@ extension KMPPubNub {
)
)
})

// Establishes an association to infer which Swift listener
// corresponds to which KMP listener
listener.underlying = swiftStatusListener

return swiftStatusListener
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/PubNub/KMP/Wrappers/KMPEventListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class KMPEventListener: NSObject {
// Stores a reference to the Swift listener that acts as a proxy
// and forwards all calls to this (KMPEventListener) instance
weak var underlying: EventListener?

@objc public init(
onMessage: ((KMPMessage) -> Void)?,
onPresence: (([KMPPresenceChange]) -> Void)?,
Expand Down
2 changes: 1 addition & 1 deletion Sources/PubNub/KMP/Wrappers/KMPStatusListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Foundation
public class KMPStatusListener: NSObject {
@objc public let uuid: UUID
@objc public var onStatusChange: ((KMPConnectionStatus) -> Void)?

// Stores a reference to the Swift listener that acts as a proxy
// and forwards all calls to this (KMPStatusListener) instance
weak var underlying: StatusListener?
Expand Down
4 changes: 2 additions & 2 deletions Sources/PubNub/Subscription/ConnectionStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public enum ConnectionStatus: Equatable {
case disconnectedUnexpectedly(PubNubError)
/// Unable to establish initial connection. Applies if `enableEventEngine` in `PubNubConfiguration` is true.
case connectionError(PubNubError)
/// SDK subscribed with a new mix of channels (fired every time the channel/channel group mix changed)
/// since the initial connection
/// Indicates that the SDK has subscribed to new channels or channel groups.
/// This status is triggered each time the channel or channel group mix changes after the initial connection, and it provides all currently subscribed channels and channel groups
case subscriptionChanged(channels: [String], groups: [String])

/// If the connection is connected or attempting to connect
Expand Down

0 comments on commit fdc64fd

Please sign in to comment.