socketio / socket.io-client-swift

Other
5.21k stars 839 forks source link

starscream version (4.0.6) #1450

Closed 9oHigh closed 12 months ago

9oHigh commented 1 year ago

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

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

raf-wtag commented 1 year ago

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

chocoford commented 1 year ago

Same question

Fernando487 commented 1 year ago

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"
raf-wtag commented 1 year ago

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

Fernando487 commented 1 year ago

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

Lves commented 1 year ago

Podfile add:

 pod 'Starscream', :git => 'https://github.com/daltoniam/Starscream.git', :tag => '4.0.4'
ZacheryWagner commented 1 year ago

Podfile add:

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

This worked for me, thank you!

raf-wtag commented 1 year ago

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

chocoford commented 1 year ago

@raf-wtag

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

or image

It is worked for me

raf-wtag commented 1 year ago

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.

chocoford commented 1 year ago

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.

raf-wtag commented 1 year ago

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

slice-dharamd commented 1 year ago

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

PaoloLongato commented 1 year ago

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.

slice-dharamd commented 1 year ago

Tested Just now with this, the build completes successfully

PaoloLongato commented 1 year ago

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.

raf-wtag commented 1 year ago

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

metalurgical commented 1 year ago

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

slice-dharamd commented 1 year ago

@raf-wtag I locked the version of Starscream

nuclearace commented 1 year ago

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")

raf-wtag commented 1 year ago

Hello @nuclearace, I've tried import socket-IO by checking out the development branch. It is working but -

I've a confusion regarding this, I thought as here the Starscream version is locked this should download the 4.0.4 but after adding the socket-IO using development branch I'm noticing that it downloads the latest starscream version 4.0.4 but it is building successfully. Whereas If I checked out using 16.0.1 the starscream version is same (4.0.6) but the delegate problem persists.

machl commented 1 year ago

@raf-wtag I had the same issue. Try cache reset for SPM or delete Pods/Socket.IO-Client-Swift and Pods/Starscream and let them download again.

nuclearace commented 1 year ago

Should be fixed in 16.1.0

filipepereira-ag commented 1 year ago

The fix was made for the Swift package manager only. The podspec file is using starscream version 4.0.6.

nuclearace commented 1 year ago

@filipepereira-ag 16.1.0 should have podspec set to 4.0.6 with an updated SocketEngine implementation. Make sure you clear any previous build data before updating pods

raf-wtag commented 12 months ago

Yes it's working. Thank you @nuclearace

9oHigh commented 12 months ago

Thank you for your quick handling : ) I'll close the issue.

dancosta-fed commented 11 months ago

Should be fixed in 16.1.0

One question about this... would I have to update my swift version as well? I've done that.. but now, getting errors like so:

.../platforms/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:87:43: error: 
      a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
GDTCORNetworkType GDTCORNetworkTypeMessage() {
                                          ^
                                           void
.../platforms/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:102:61: error: 
      a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
GDTCORNetworkMobileSubtype GDTCORNetworkMobileSubTypeMessage() {
                                                            ^
                                                             void
.../platforms/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:157:37: error: 
      a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
NSString *_Nonnull GDTCORDeviceModel() {
                                    ^
                                     void
3 errors generated.

I could just open the files and add (void) to them, as it indicates. But I genuinely don't know if that's ideal... especially because I use bitrise to handle my apps. And if I hard coded that.. I'd have to find away to make that work later on a bitrise machine (maybe through podFiles?)...

anyways... any ideas? Does that make sense?