Skip to content

Conversation

@ciospettw
Copy link

Summary

Starscream 5.x changed the WebSocketDelegate API to use WebSocketClient instead of WebSocket. This PR updates CocoaMQTT's WebSocket integration to compile with Starscream 5.x while preserving compatibility with 4.x, and relaxes dependency constraints so downstream projects can resolve either version.

Motivation

  • Projects pinning Starscream 5.x fail to compile CocoaMQTT due to:
    • Type 'CocoaMQTTWebSocket.StarscreamConnection' does not conform to protocol 'WebSocketDelegate'
    • Candidate has non-matching type '(WebSocketEvent, WebSocket) -> ()'
  • Conversely, some apps still pin Starscream 4.x, so a 5.x-only requirement breaks their resolution.

Changes

Source/CocoaMQTTWebSocket.swift

  • Update WebSocketDelegate implementation to the 5.x signature:
    • didReceive(event: WebSocketEvent, client: WebSocketClient)
  • Add a backward-compatible overload for 4.x:
    • didReceive(event: WebSocketEvent, client: WebSocket)
  • The 4.x overload forwards to the 5.x-style handler to avoid duplicate logic. No behavior changes.

Package.swift

  • Relax Starscream dependency to allow both 4.x and 5.x:
    • "4.0.8" ..< "6.0.0"
  • Note: tools-version bumped to 5.7 in this PR. If you prefer to keep 5.0, I can revert—this change isn't strictly required for the code update.

CocoaMQTT.podspec

  • Relax Starscream dependency for CocoaPods:
    • ">= 4.0.4", "< 6.0"

Backward compatibility

  • Compiles and runs with both Starscream 4.x and 5.x
  • CocoaMQTT public API is unchanged
  • No runtime behavior changes

Testing

  • Built CocoaMQTT against:
    • Starscream 4.0.8 (app pinned to 4.x)
    • Starscream 5.x (app pinned to 5.x)
  • Verified the delegate events flow through unchanged (connect, disconnect, text/binary, error)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant