Skip to content

Commit

Permalink
Upgrading PubNub Swift SDK (#188)
Browse files Browse the repository at this point in the history
feat(module): replace module name with PubNubSDK (swiftlang/swift#56573)

feat(subscribe): add new subscriptionChanged(channels, groups) status, remove connecting and reconnecting cases

feat(reconnection-policy): remove .legacyExponential(base, scale, maxDelay) reconnection policy

feat(objects): add additional fields to fetch in PubNub.MembershipInclude and PubNub.MemberInclude

feat(configuration): set default AutomaticRetry for retrying subscribe requests with exponential reconnection policy

feat(listeners): add support for attaching additional listeners to Subscription and SubscriptionSet

fix(listeners): ensure that subscriptions are always internally stored as weak references
  • Loading branch information
jguz-pubnub authored Sep 23, 2024
1 parent a72d552 commit 7ec9708
Show file tree
Hide file tree
Showing 204 changed files with 4,774 additions and 1,006 deletions.
21 changes: 19 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
---
name: swift
scm: github.com/pubnub/swift
version: "7.3.3"
version: "8.0.0"
schema: 1
changelog:
- date: 2024-09-23
version: 8.0.0
changes:
- type: feature
text: "Replace module name with `PubNubSDK` due to compiler error when a public type shares the same name as the module."
- type: feature
text: " add new `subscriptionChanged(channels, groups)` connection status and remove previously deprecated `connecting` and `reconnecting` cases."
- type: feature
text: "Remove previously deprecated `.legacyExponential(base, scale, maxDelay)` reconnection policy."
- type: feature
text: "Added additional fields to fetch in `PubNub.MembershipInclude` and `PubNub.MemberInclude`."
- type: feature
text: "Set default `AutomaticRetry` for retrying subscribe requests with exponential reconnection policy."
- type: feature
text: "Add support for attaching additional listeners to `Subscription` and `SubscriptionSet`."
- type: bug
text: "Ensure that subscriptions are always internally stored as weak references."
- date: 2024-09-13
version: 7.3.3
changes:
Expand Down Expand Up @@ -569,7 +586,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: PubNub
location: https://github.com/pubnub/swift/archive/refs/tags/7.3.3.zip
location: https://github.com/pubnub/swift/archive/refs/tags/8.0.0.zip
supported-platforms:
supported-operating-systems:
macOS:
Expand Down
21 changes: 21 additions & 0 deletions Documentation/PubNub_8_0_Migration_Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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

### `ReconnectionPolicy`

* The `.legacyExponential(base, scale, maxDelay)` enumeration case from `AutomaticRetry.ReconnectionPolicy` is no longer supported. Use `.exponential(minDelay, maxDelay)` instead
* `PubNubConfiguration` uses default `AutomaticRetry` with an exponential reconnection policy to retry Subscribe requests in case of failure. If this behavior doesn’t suit your use case, you can pass custom `AutomaticRetry` object

### `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`
10 changes: 5 additions & 5 deletions Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
359F779F22B7FEF700B6B46F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 359F779E22B7FEF700B6B46F /* Assets.xcassets */; };
359F77A222B7FEF700B6B46F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 359F77A022B7FEF700B6B46F /* LaunchScreen.storyboard */; };
35F0258F22BAC6C9007BD7D3 /* ConfigDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35F0258E22BAC6C9007BD7D3 /* ConfigDetailTableViewController.swift */; };
3D26A6152C6BB68A007B4539 /* PubNubSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 3D26A6142C6BB68A007B4539 /* PubNubSDK */; };
3D34160D2BB5CE20008558A0 /* DetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D34160C2BB5CE20008558A0 /* DetailTableViewController.swift */; };
792CF27228C4FBB300C83408 /* PubNub in Frameworks */ = {isa = PBXBuildFile; productRef = 792CF27128C4FBB300C83408 /* PubNub */; };
792CF27428C4FBB300C83408 /* PubNubMembership in Frameworks */ = {isa = PBXBuildFile; productRef = 792CF27328C4FBB300C83408 /* PubNubMembership */; };
792CF27628C4FBB300C83408 /* PubNubSpace in Frameworks */ = {isa = PBXBuildFile; productRef = 792CF27528C4FBB300C83408 /* PubNubSpace */; };
792CF27828C4FBB300C83408 /* PubNubUser in Frameworks */ = {isa = PBXBuildFile; productRef = 792CF27728C4FBB300C83408 /* PubNubUser */; };
Expand Down Expand Up @@ -70,9 +70,9 @@
buildActionMask = 2147483647;
files = (
792CF27428C4FBB300C83408 /* PubNubMembership in Frameworks */,
3D26A6152C6BB68A007B4539 /* PubNubSDK in Frameworks */,
792CF27828C4FBB300C83408 /* PubNubUser in Frameworks */,
792CF27628C4FBB300C83408 /* PubNubSpace in Frameworks */,
792CF27228C4FBB300C83408 /* PubNub in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -176,10 +176,10 @@
);
name = "iOS Example";
packageProductDependencies = (
792CF27128C4FBB300C83408 /* PubNub */,
792CF27328C4FBB300C83408 /* PubNubMembership */,
792CF27528C4FBB300C83408 /* PubNubSpace */,
792CF27728C4FBB300C83408 /* PubNubUser */,
3D26A6142C6BB68A007B4539 /* PubNubSDK */,
);
productName = swiftSdkiOS;
productReference = 359F779422B7FEF600B6B46F /* iOS Example.app */;
Expand Down Expand Up @@ -464,9 +464,9 @@
/* End XCConfigurationList section */

/* Begin XCSwiftPackageProductDependency section */
792CF27128C4FBB300C83408 /* PubNub */ = {
3D26A6142C6BB68A007B4539 /* PubNubSDK */ = {
isa = XCSwiftPackageProductDependency;
productName = PubNub;
productName = PubNubSDK;
};
792CF27328C4FBB300C83408 /* PubNubMembership */ = {
isa = XCSwiftPackageProductDependency;
Expand Down
3 changes: 1 addition & 2 deletions Examples/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
//

import UIKit

import PubNub
import PubNubSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand Down
3 changes: 1 addition & 2 deletions Examples/Sources/ConfigDetailTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
//

import UIKit

import PubNub
import PubNubSDK

class ConfigDetailTableViewController: UITableViewController {

Expand Down
8 changes: 3 additions & 5 deletions Examples/Sources/DetailTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import Foundation
import UIKit

import PubNub
import PubNubSDK
import PubNubMembership
import PubNubSpace
import PubNubUser
Expand Down Expand Up @@ -249,12 +249,10 @@ class DetailTableViewController: UITableViewController {
print("The signal is \(signal.payload) and was sent by \(signal.publisher ?? "")")
case let .connectionStatusChanged(connectionChange):
switch connectionChange {
case .connecting:
print("Status connecting...")
case .connected:
print("Status connected!")
case .reconnecting:
print("Status reconnecting...")
case .subscriptionChanged:
print("Subscription changed")
case .disconnected:
print("Status disconnected")
case .disconnectedUnexpectedly:
Expand Down
3 changes: 1 addition & 2 deletions Examples/Sources/File/FileAPIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
//

import UIKit

import PubNub
import PubNubSDK

enum AlertMessageDirection: String {
case upload = "Uploading"
Expand Down
3 changes: 1 addition & 2 deletions Examples/Sources/File/LocalFileExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
//

import Foundation

import PubNub
import PubNubSDK

enum FileError: Error {
case fileNameError
Expand Down
21 changes: 11 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.9
//
// Package.swift
//
Expand All @@ -12,18 +12,19 @@
import PackageDescription

let package = Package(
name: "PubNub",
name: "PubNubSDK",
platforms: [
.iOS(.v12),
.macOS(.v10_15),
.tvOS(.v12),
.watchOS(.v4)
.watchOS(.v4),
.visionOS(.v1)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "PubNub",
targets: ["PubNub"]
name: "PubNubSDK",
targets: ["PubNubSDK"]
),
.library(
name: "PubNubUser",
Expand All @@ -45,28 +46,28 @@ let package = Package(
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "PubNub",
name: "PubNubSDK",
path: "Sources/PubNub",
resources: [.copy("PrivacyInfo.xcprivacy")]
),
.target(
name: "PubNubUser",
dependencies: ["PubNub"],
dependencies: ["PubNubSDK"],
path: "PubNubUser/Sources"
),
.target(
name: "PubNubSpace",
dependencies: ["PubNub"],
dependencies: ["PubNubSDK"],
path: "PubNubSpace/Sources"
),
.target(
name: "PubNubMembership",
dependencies: ["PubNub", "PubNubUser", "PubNubSpace"],
dependencies: ["PubNubSDK", "PubNubUser", "PubNubSpace"],
path: "PubNubMembership/Sources"
),
.testTarget(
name: "PubNubTests",
dependencies: ["PubNub"]
dependencies: ["PubNubSDK"]
)
],
swiftLanguageVersions: [.v5]
Expand Down
Loading

0 comments on commit 7ec9708

Please sign in to comment.