Skip to content

Commit 0fce454

Browse files
authored
Merge pull request #214 from pusher/update-to-swift4.2
Update to Swift 4.2
2 parents 33d994e + c1f70bc commit 0fce454

File tree

8 files changed

+38
-37
lines changed

8 files changed

+38
-37
lines changed

PusherSwift.podspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Pod::Spec.new do |s|
88
s.source = { git: "https://github.com/pusher/pusher-websocket-swift.git", tag: s.version.to_s }
99
s.social_media_url = 'https://twitter.com/pusher'
1010

11-
s.requires_arc = true
12-
s.source_files = 'Sources/*.swift'
11+
s.swift_version = '4.2'
12+
s.requires_arc = true
13+
s.source_files = 'Sources/*.swift'
1314

1415
s.dependency 'CryptoSwift', '~> 0.9'
1516
s.dependency 'ReachabilitySwift', '4.3.0'

PusherSwift.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@
246246
TargetAttributes = {
247247
33831C881A9CF61600B124F1 = {
248248
CreatedOnToolsVersion = 6.3;
249-
LastSwiftMigration = 0800;
249+
LastSwiftMigration = 1010;
250250
};
251251
33831C931A9CF61600B124F1 = {
252252
CreatedOnToolsVersion = 6.3;
253-
LastSwiftMigration = 0800;
253+
LastSwiftMigration = 1010;
254254
};
255255
};
256256
};
@@ -498,7 +498,7 @@
498498
SKIP_INSTALL = YES;
499499
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvsimulator appletvos";
500500
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
501-
SWIFT_VERSION = 4.0;
501+
SWIFT_VERSION = 4.2;
502502
TARGETED_DEVICE_FAMILY = "1,2,3,4";
503503
TVOS_DEPLOYMENT_TARGET = 9.0;
504504
VERSIONING_SYSTEM = "apple-generic";
@@ -555,7 +555,7 @@
555555
SDKROOT = "";
556556
SKIP_INSTALL = YES;
557557
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvsimulator appletvos";
558-
SWIFT_VERSION = 4.0;
558+
SWIFT_VERSION = 4.2;
559559
TARGETED_DEVICE_FAMILY = "1,2,3,4";
560560
TVOS_DEPLOYMENT_TARGET = 9.0;
561561
VALIDATE_PRODUCT = YES;
@@ -613,7 +613,7 @@
613613
SDKROOT = "";
614614
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvsimulator appletvos";
615615
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
616-
SWIFT_VERSION = 4.0;
616+
SWIFT_VERSION = 4.2;
617617
TVOS_DEPLOYMENT_TARGET = 9.0;
618618
};
619619
name = Debug;
@@ -659,7 +659,7 @@
659659
PRODUCT_NAME = PusherSwiftTests;
660660
SDKROOT = "";
661661
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvsimulator appletvos";
662-
SWIFT_VERSION = 4.0;
662+
SWIFT_VERSION = 4.2;
663663
TVOS_DEPLOYMENT_TARGET = 9.0;
664664
VALIDATE_PRODUCT = YES;
665665
};

Sources/ObjectiveC.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
import Foundation
22

33
@objc public extension Pusher {
4-
public func subscribe(channelName: String) -> PusherChannel {
4+
func subscribe(channelName: String) -> PusherChannel {
55
return self.subscribe(channelName, onMemberAdded: nil, onMemberRemoved: nil)
66
}
77

8-
public func subscribe(
8+
func subscribe(
99
channelName: String,
1010
onMemberAdded: ((PusherPresenceChannelMember) -> ())? = nil,
1111
onMemberRemoved: ((PusherPresenceChannelMember) -> ())? = nil
1212
) -> PusherChannel {
1313
return self.subscribe(channelName, auth: nil, onMemberAdded: onMemberAdded, onMemberRemoved: onMemberRemoved)
1414
}
1515

16-
public func subscribeToPresenceChannel(channelName: String) -> PusherPresenceChannel {
16+
func subscribeToPresenceChannel(channelName: String) -> PusherPresenceChannel {
1717
return self.subscribeToPresenceChannel(channelName: channelName, auth: nil, onMemberAdded: nil, onMemberRemoved: nil)
1818
}
1919

20-
public func subscribeToPresenceChannel(
20+
func subscribeToPresenceChannel(
2121
channelName: String,
2222
onMemberAdded: ((PusherPresenceChannelMember) -> ())? = nil,
2323
onMemberRemoved: ((PusherPresenceChannelMember) -> ())? = nil
2424
) -> PusherPresenceChannel {
2525
return self.subscribeToPresenceChannel(channelName: channelName, auth: nil, onMemberAdded: onMemberAdded, onMemberRemoved: onMemberRemoved)
2626
}
2727

28-
public convenience init(withAppKey key: String, options: PusherClientOptions) {
28+
convenience init(withAppKey key: String, options: PusherClientOptions) {
2929
self.init(key: key, options: options)
3030
}
3131

32-
public convenience init(withKey key: String) {
32+
convenience init(withKey key: String) {
3333
self.init(key: key)
3434
}
3535
}
3636

3737
@objc public extension PusherConnection {
38-
public var OCReconnectAttemptsMax: NSNumber? {
38+
var OCReconnectAttemptsMax: NSNumber? {
3939
get {
4040
return reconnectAttemptsMax as NSNumber?
4141
}
@@ -44,7 +44,7 @@ import Foundation
4444
}
4545
}
4646

47-
public var OCMaxReconnectGapInSeconds: NSNumber? {
47+
var OCMaxReconnectGapInSeconds: NSNumber? {
4848
get {
4949
return maxReconnectGapInSeconds as NSNumber?
5050
}
@@ -55,7 +55,7 @@ import Foundation
5555
}
5656

5757
@objc public extension PusherClientOptions {
58-
public convenience init(
58+
convenience init(
5959
ocAuthMethod authMethod: OCAuthMethod,
6060
attemptToReturnJSONObject: Bool = true,
6161
autoReconnect: Bool = true,
@@ -75,11 +75,11 @@ import Foundation
7575
)
7676
}
7777

78-
public convenience init(authMethod: OCAuthMethod) {
78+
convenience init(authMethod: OCAuthMethod) {
7979
self.init(authMethod: AuthMethod.fromObjc(source: authMethod))
8080
}
8181

82-
public func setAuthMethod(authMethod: OCAuthMethod) {
82+
func setAuthMethod(authMethod: OCAuthMethod) {
8383
self.authMethod = AuthMethod.fromObjc(source: authMethod)
8484
}
8585
}

Sources/PusherChannel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public enum PusherChannelType {
2828
open class PusherChannel: NSObject {
2929
open var eventHandlers: [String: [EventHandler]] = [:]
3030
open var subscribed = false
31-
open let name: String
31+
public let name: String
3232
open weak var connection: PusherConnection?
3333
open var unsentEvents = [PusherEvent]()
34-
open let type: PusherChannelType
34+
public let type: PusherChannelType
3535
public var auth: PusherAuth?
3636

3737
/**

Sources/PusherConnection.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public typealias PusherEventJSON = [String: AnyObject]
77

88
@objcMembers
99
@objc open class PusherConnection: NSObject {
10-
open let url: String
11-
open let key: String
10+
public let url: String
11+
public let key: String
1212
open var options: PusherClientOptions
1313
open var globalChannel: GlobalChannel!
1414
open var socketId: String?
@@ -42,42 +42,42 @@ public typealias PusherEventJSON = [String: AnyObject]
4242
open lazy var reachability: Reachability? = {
4343
let reachability = Reachability.init()
4444
reachability?.whenReachable = { [weak self] reachability in
45-
guard let strongSelf = self else {
45+
guard let self = self else {
4646
print("Your Pusher instance has probably become deallocated. See https://github.com/pusher/pusher-websocket-swift/issues/109 for more information")
4747
return
4848
}
4949

50-
strongSelf.delegate?.debugLog?(message: "[PUSHER DEBUG] Network reachable")
50+
self.delegate?.debugLog?(message: "[PUSHER DEBUG] Network reachable")
5151

52-
switch strongSelf.connectionState {
52+
switch self.connectionState {
5353
case .disconnecting, .connecting, .reconnecting:
5454
// If in one of these states then part of the connection, reconnection, or explicit
5555
// disconnection process is underway, so do nothing
5656
return
5757
case .disconnected:
5858
// If already disconnected then reset connection and try to reconnect, provided the
5959
// state isn't disconnected because of an intentional disconnection
60-
if !strongSelf.intentionalDisconnect { strongSelf.resetConnectionAndAttemptReconnect() }
60+
if !self.intentionalDisconnect { self.resetConnectionAndAttemptReconnect() }
6161
return
6262
case .connected:
6363
// If already connected then we assume that there was a missed network event that
6464
// led to a bad connection so we move to the disconnected state and then attempt
6565
// reconnection
66-
strongSelf.delegate?.debugLog?(
67-
message: "[PUSHER DEBUG] Connection state is \(self!.connectionState.stringValue()) but received network reachability change so going to call attemptReconnect"
66+
self.delegate?.debugLog?(
67+
message: "[PUSHER DEBUG] Connection state is \(self.connectionState.stringValue()) but received network reachability change so going to call attemptReconnect"
6868
)
69-
strongSelf.resetConnectionAndAttemptReconnect()
69+
self.resetConnectionAndAttemptReconnect()
7070
return
7171
}
7272
}
7373
reachability?.whenUnreachable = { [weak self] reachability in
74-
guard let strongSelf = self else {
74+
guard let self = self else {
7575
print("Your Pusher instance has probably become deallocated. See https://github.com/pusher/pusher-websocket-swift/issues/109 for more information")
7676
return
7777
}
7878

79-
strongSelf.delegate?.debugLog?(message: "[PUSHER DEBUG] Network unreachable")
80-
strongSelf.resetConnectionAndAttemptReconnect()
79+
self.delegate?.debugLog?(message: "[PUSHER DEBUG] Network unreachable")
80+
self.resetConnectionAndAttemptReconnect()
8181
}
8282
return reachability
8383
}()

Sources/PusherSwift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let CLIENT_NAME = "pusher-websocket-swift"
77

88
@objcMembers
99
@objc open class Pusher: NSObject {
10-
open let connection: PusherConnection
10+
public let connection: PusherConnection
1111
open weak var delegate: PusherDelegate? = nil {
1212
willSet {
1313
self.connection.delegate = newValue

Tests/Mocks.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ open class StubberForMocks {
249249
}
250250

251251
open class FunctionCall {
252-
open let name: String
253-
open let args: [Any]?
252+
public let name: String
253+
public let args: [Any]?
254254

255255
init(name: String, args: [Any]?) {
256256
self.name = name

Tests/PusherConnectionDelegateTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import XCTest
33

44
class PusherConnectionDelegateTests: XCTestCase {
55
open class DummyDelegate: PusherDelegate {
6-
open let stubber = StubberForMocks()
6+
public let stubber = StubberForMocks()
77
open var socket: MockWebSocket? = nil
88
open var ex: XCTestExpectation? = nil
99
var testingChannelName: String? = nil

0 commit comments

Comments
 (0)