starscream version (4.0.6)
Recent updates to starcream cause the following problems when using version 16.0.1.
"Type 'SocketEngine' does not conform to protocol 'WebSocketDelegate'"
I'm getting the same issue. Last week this was working as expected but now.
Same question
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"
Hello @Fernando487, I want to import using swift package manager. So do I have to use development branch instead of a exact version number?
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
Podfile add:
pod 'Starscream', :git => 'https://github.com/daltoniam/Starscream.git', :tag => '4.0.4'
Podfile add:
pod 'Starscream', :git => 'https://github.com/daltoniam/Starscream.git', :tag => '4.0.4'
This worked for me, thank you!
@Lves If I want to add socket-IO using SPM how can I declare the version of the Starscream?
@raf-wtag
.package(url: "https://github.com/daltoniam/Starscream", exact: "4.0.4"),
or
It is worked for me
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.
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.
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
Hoping for a new version release, if this will get this fixed.
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.
Tested Just now with this, the build completes successfully
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.
@slice-dharamd do you lock the version of Starscream or you get the proper Starscream version from Scok-IO directly?
Still breaks for swift package manager, for 16.0.1, perhaps release a patch update (16.0.2)?
@raf-wtag I locked the version of Starscream
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")