Swiftpack.co - moozzyk/SignalR-Client-Swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by moozzyk.
moozzyk/SignalR-Client-Swift 0.9.2
Swift SignalR Client for Asp.Net Core SignalR server
⭐️ 302
🕓 4 weeks ago
.package(url: "https://github.com/moozzyk/SignalR-Client-Swift.git", from: "0.9.2")


A Swift SignalR Client for the Asp.Net Core version of SignalR

Before filing an issue please check Frequently Asked Questions



Add the following lines to your Podfile:

pod 'SwiftSignalRClient'

Then run:

pod install

Swift Package Manager

Add the following to your Package dependencies:

.package(url: "https://github.com/moozzyk/SignalR-Client-Swift", .upToNextMinor(from: "0.6.0")),

Then include "SignalRClient" in your target dependencies. For example:

.target(name: "MySwiftPackage", dependencies: ["SignalRClient"]),


Add the following lines to your Cartfile:

github "moozzyk/SignalR-Client-Swift"

Then run:

carthage update


Add import SwiftSignalRClient (or import SignalRClient if you are using Swift Package Manager) to swift files you would like to use the client in.

A typical implementation looks like the following:

import Foundation
import SwiftSignalRClient

public class SignalRService {
    private var connection: HubConnection
    public init(url: URL) {
        connection = HubConnectionBuilder(url: url).withLogging(minLogLevel: .error).build()
        connection.on(method: "MessageReceived", callback: { (user: String, message: String) in
            do {
                self.handleMessage(message, from: user)
            } catch {
    private func handleMessage(_ message: String, from user: String) {
        // Do something with the message.

More detailed user's guide:


There are several sample projects in the Examples folder. They include:

  • SignalRClient.xcodeproj

    An Xcode workspace that has compiled libraries for macOS (OSX) and iOS, along with the Application targets 'ConnectionSample', 'HubSample', and 'HubSamplePhone'.

  • TestServer

    A .Net solution that the unit tests and samples can be run against.

    The TestServer Requires .NET Core SDK 3.0.100 or later.

    To run, navigate to the TestServer folder and execute the following in the terminal:

    % npm install
    % dotnet run

    When running the TestServer project on macOS Monterey (12.0 or greater), you may encounter the error: "Failed to bind to address address already in use.". This is due to Apple now advertising an 'AirPlay Receiver' on that port. This port can be freed by disabling the receiver: Navigate to System Preferences > Sharing and uncheck AirPlay Receiver.


I am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my code is from me and not my employer (Facebook)




Stars: 302
Last commit: 2 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

4 weeks ago

Issues fixed:

  • deadlock that would occur when a keep-alive was sent during reconnects
  • connectionId getter doesn't return the connection Id
  • authenticationChallengeHandler was lost when creating a connection making it impossible to handle challenges issued by a server

New Contributors

Full Changelog: https://github.com/moozzyk/SignalR-Client-Swift/compare/0.9.1...0.9.2

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics