Skip to content

Commit 13bf50e

Browse files
committed
Makes the NativePusher code only available (and built) if the target
is iOS.
1 parent 449a019 commit 13bf50e

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

PusherSwift/PusherSwift.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
3389F57C1CAEDEC800563F49 /* PusherClientOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3389F5791CAEDEC800563F49 /* PusherClientOptions.swift */; };
3737
33999D261C401F9600AFED30 /* PusherSwift.h in Headers */ = {isa = PBXBuildFile; fileRef = 33831CD61A9CFFF200B124F1 /* PusherSwift.h */; settings = {ATTRIBUTES = (Public, ); }; };
3838
33999D381C4020A300AFED30 /* PusherSwift.h in Headers */ = {isa = PBXBuildFile; fileRef = 33831CD61A9CFFF200B124F1 /* PusherSwift.h */; settings = {ATTRIBUTES = (Public, ); }; };
39-
339A49191D2DA70F00399699 /* NativePusher.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD7424A81D1459B700CED79C /* NativePusher.swift */; };
40-
339A491A1D2DA71000399699 /* NativePusher.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD7424A81D1459B700CED79C /* NativePusher.swift */; };
4139
33BB99731D21230100B25C2A /* AuthenticationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33BB995D1D21226C00B25C2A /* AuthenticationTests.swift */; };
4240
33BB99741D21230100B25C2A /* ConnectionStateChangeDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33BB995E1D21226C00B25C2A /* ConnectionStateChangeDelegateTests.swift */; };
4341
33BB99751D21230100B25C2A /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33BB995F1D21226C00B25C2A /* Helpers.swift */; };
@@ -797,7 +795,6 @@
797795
3389F5771CAEDE2800563F49 /* PusherGlobalChannel.swift in Sources */,
798796
3389F57B1CAEDEC800563F49 /* PusherClientOptions.swift in Sources */,
799797
3389F56F1CAEDDD800563F49 /* PusherPresenceChannel.swift in Sources */,
800-
339A49191D2DA70F00399699 /* NativePusher.swift in Sources */,
801798
33C0D2E51CB5C539003FE13E /* Reachability.swift in Sources */,
802799
33C0D2D61CB5C1F2003FE13E /* CryptoSwiftHMACModule.swift in Sources */,
803800
33C0D2DC1CB5C364003FE13E /* Starscream.swift in Sources */,
@@ -816,7 +813,6 @@
816813
3389F5781CAEDE2800563F49 /* PusherGlobalChannel.swift in Sources */,
817814
3389F57C1CAEDEC800563F49 /* PusherClientOptions.swift in Sources */,
818815
3389F5701CAEDDD800563F49 /* PusherPresenceChannel.swift in Sources */,
819-
339A491A1D2DA71000399699 /* NativePusher.swift in Sources */,
820816
33C0D2E61CB5C539003FE13E /* Reachability.swift in Sources */,
821817
33C0D2D71CB5C1F2003FE13E /* CryptoSwiftHMACModule.swift in Sources */,
822818
33C0D2DD1CB5C364003FE13E /* Starscream.swift in Sources */,

Source/PusherSwift.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class Pusher {
1515
public let connection: PusherConnection
1616
private let key: String
1717

18+
#if os(iOS)
1819
/**
1920
Initializes the Pusher client with an app key and any appropriate options.
2021

@@ -31,6 +32,25 @@ public class Pusher {
3132
connection.createGlobalChannel()
3233
nativePusher.setPusherAppKey(key)
3334
}
35+
#endif
36+
37+
#if os(OSX) || os(tvOS)
38+
/**
39+
Initializes the Pusher client with an app key and any appropriate options.
40+
41+
- parameter key: The Pusher app key
42+
- parameter options: An optional collection of options
43+
44+
- returns: A new Pusher client instance
45+
*/
46+
public init(key: String, options: PusherClientOptions = PusherClientOptions()) {
47+
self.key = key
48+
let urlString = constructUrl(key, options: options)
49+
let ws = WebSocket(url: NSURL(string: urlString)!)
50+
connection = PusherConnection(key: key, socket: ws, url: urlString, options: options)
51+
connection.createGlobalChannel()
52+
}
53+
#endif
3454

3555
/**
3656
Subscribes the client to a new channel
@@ -100,6 +120,7 @@ public class Pusher {
100120
self.connection.connect()
101121
}
102122

123+
#if os(iOS)
103124
/**
104125
Returns the NativePusher singletion
105126

@@ -108,6 +129,7 @@ public class Pusher {
108129
public func nativePusher() -> NativePusher {
109130
return NativePusher.sharedInstance
110131
}
132+
#endif
111133
}
112134

113135
/**

0 commit comments

Comments
 (0)