socket.io-client-swift icon indicating copy to clipboard operation
socket.io-client-swift copied to clipboard

starscream version (4.0.6)

Open 9oHigh opened this issue 3 years ago • 28 comments

Recent updates to starcream cause the following problems when using version 16.0.1.

"Type 'SocketEngine' does not conform to protocol 'WebSocketDelegate'"

9oHigh avatar Aug 20 '23 08:08 9oHigh

I'm getting the same issue. Last week this was working as expected but now.

raf-wtag avatar Aug 20 '23 08:08 raf-wtag

Same question

chocoford avatar Aug 20 '23 13:08 chocoford

Hi, you need to use development branch if use Pods add this on your target

pod 'Socket.IO-Client-Swift', :git => 'https://github.com/socketio/socket.io-client-swift.git', :branch => 'development'

then open on xcode the file SocketEngine.swift and add the nex code in the beginig

the file are Pods > Socket.IO.Client-Swift > SocketEngine.swift

public func didReceive(event: Starscream.WebSocketEvent, client: Starscream.WebSocketClient) { // TODO: Implement this method later switch event { case let .connected(headers): wsConnected = true self.client?.engineDidWebsocketUpgrade(headers: headers) websocketDidConnect() case .cancelled: wsConnected = false websocketDidDisconnect(error: EngineError.canceled) case .disconnected(_, _): wsConnected = false websocketDidDisconnect(error: nil) case let .text(msg): parseEngineMessage(msg) case let .binary(data): parseEngineData(data) case _: break } }

your beginging code looks like

open class SocketEngine: NSObject, WebSocketDelegate, URLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket, ConfigSettable { public func didReceive(event: Starscream.WebSocketEvent, client: Starscream.WebSocketClient) { // TODO: Implement this method later switch event { case let .connected(headers): wsConnected = true self.client?.engineDidWebsocketUpgrade(headers: headers) websocketDidConnect() case .cancelled: wsConnected = false websocketDidDisconnect(error: EngineError.canceled) case .disconnected(_, _): wsConnected = false websocketDidDisconnect(error: nil) case let .text(msg): parseEngineMessage(msg) case let .binary(data): parseEngineData(data) case _: break } }

// MARK: Properties

private static let logType = "SocketEngine"

Fernando487 avatar Aug 21 '23 00:08 Fernando487

Hello @Fernando487, I want to import using swift package manager. So do I have to use development branch instead of a exact version number?

raf-wtag avatar Aug 21 '23 03:08 raf-wtag

yes someting like this dependencies: [ .package(url: "https://github.com/socketio/socket.io-client-swift", .branch("development")) ]

an then change the code with my coding fix

Fernando487 avatar Aug 21 '23 03:08 Fernando487

Podfile add:

 pod 'Starscream', :git => 'https://github.com/daltoniam/Starscream.git', :tag => '4.0.4'

ewb-xingle avatar Aug 21 '23 08:08 ewb-xingle

Podfile add:

 pod 'Starscream', :git => 'https://github.com/daltoniam/Starscream.git', :tag => '4.0.4'

This worked for me, thank you!

ZacheryWagner avatar Aug 21 '23 10:08 ZacheryWagner

@Lves If I want to add socket-IO using SPM how can I declare the version of the Starscream?

raf-wtag avatar Aug 21 '23 11:08 raf-wtag

@raf-wtag

.package(url: "https://github.com/daltoniam/Starscream", exact: "4.0.4"),

or image

It is worked for me

chocoford avatar Aug 21 '23 12:08 chocoford

Yes but as the starscream was being downloaded by the socket-IO itself, should I download the Starscream before the Socket-IO pod? Context: Using Swift Package Manager.

raf-wtag avatar Aug 21 '23 12:08 raf-wtag

Yes but as the starscream was being downloaded by the socket-IO itself, should I download the Starscream before the Socket-IO pod? Context: Using Swift Package Manager.

If you explicitly specify the version of Starscream, Xcode will use your declared version of Starscream.

You can just add the package then it will work.

chocoford avatar Aug 21 '23 12:08 chocoford

No need to specify the Starscream from our end as they have already added the fix here - https://github.com/socketio/socket.io-client-swift/commit/3c81d0ee55111a80a8f39b9c61782887ec98ceb4

raf-wtag avatar Aug 22 '23 03:08 raf-wtag

Hoping for a new version release, if this will get this fixed.

slice-dharamd avatar Aug 22 '23 09:08 slice-dharamd

The fix is in: https://github.com/socketio/socket.io-client-swift/commit/d7846b31a215211e595292425a2fdd6d16177faf

But there is no release yet. We need a new tag.

PaoloLongato avatar Aug 22 '23 10:08 PaoloLongato

Tested Just now with this, the build completes successfully

slice-dharamd avatar Aug 22 '23 10:08 slice-dharamd

Can we expect a proper fix that does not lock the version of Starscream? In complex projects where Starscream is also used this might cause conflicts.

PaoloLongato avatar Aug 22 '23 11:08 PaoloLongato

@slice-dharamd do you lock the version of Starscream or you get the proper Starscream version from Scok-IO directly?

raf-wtag avatar Aug 22 '23 11:08 raf-wtag

Still breaks for swift package manager, for 16.0.1, perhaps release a patch update (16.0.2)?

metalurgical avatar Aug 22 '23 14:08 metalurgical

@raf-wtag I locked the version of Starscream

slice-dharamd avatar Aug 23 '23 17:08 slice-dharamd

If people want to try building with the development branch and see if that is building for you, I will merge to master and cut a new release.

pod 'Socket.IO-Client-Swift', git: 'https://github.com/socketio/socket.io-client-swift.git', branch: 'development'

.package(url: "https://github.com/socketio/socket.io-client-swift", branch: "development")

nuclearace avatar Aug 25 '23 14:08 nuclearace