Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Latest commit 19a1774 Jan 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
Socket.IO-Client-Swift.xcodeproj Fix #1147 Jan 11, 2019
SocketIO Rename header file; add armv7k arch Oct 7, 2017
Source/SocketIO config setting and test updates for reconnectWaitMax and randomizatio… Jan 12, 2019
Tests config setting and test updates for reconnectWaitMax and randomizatio… Jan 12, 2019
Usage Docs Update Jul 20, 2018
docs bump version and docs Jan 16, 2019
.travis.yml update xcode versino Sep 18, 2018 update readme and changelog for new version Jan 16, 2019
LICENSE add podspec for v1.1.0 and LICENSE Mar 12, 2015
Package.swift update readme and changelog for new version Jan 16, 2019

Build Status


Socket.IO-client for iOS/OS X.


import SocketIO

let manager = SocketManager(socketURL: URL(string: "http://localhost:8080")!, config: [.log(true), .compress])
let socket = manager.defaultSocket

socket.on(clientEvent: .connect) {data, ack in
    print("socket connected")

socket.on("currentAmount") {data, ack in
    guard let cur = data[0] as? Double else { return }
    socket.emitWithAck("canUpdate", cur).timingOut(after: 0) {data in
        socket.emit("update", ["amount": cur + 2.50])

    ack.with("Got your currentAmount", "dude")


Objective-C Example

@import SocketIO;

NSURL* url = [[NSURL alloc] initWithString:@"http://localhost:8080"];
SocketManager* manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log": @YES, @"compress": @YES}];
SocketIOClient* socket = manager.defaultSocket;

[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
    NSLog(@"socket connected");

[socket on:@"currentAmount" callback:^(NSArray* data, SocketAckEmitter* ack) {
    double cur = [[data objectAtIndex:0] floatValue];

    [[socket emitWithAck:@"canUpdate" with:@[@(cur)]] timingOutAfter:0 callback:^(NSArray* data) {
        [socket emit:@"update" with:@[@{@"amount": @(cur + 2.50)}]];

    [ack with:@[@"Got your currentAmount, ", @"dude"]];

[socket connect];


  • Supports 2.0+ (For 1.0 use v9.x)
  • Supports binary
  • Supports Polling and WebSockets
  • Supports TLS/SSL
  • Can be used from Objective-C


Checkout the FAQs for commonly asked questions.

Checkout the 12to13 guide for migrating to v13+ from v12 below.


Requires Swift 4/Xcode 9.x

If you need Swift 2.3 use the swift2.3 tag (Pre-Swift 4 support is no longer maintained)

If you need Swift 3.x use v11.1.3.

Swift Package Manager

Add the project as a dependency to your Package.swift:

// swift-tools-version:4.2

import PackageDescription

let package = Package(
    name: "",
    products: [
        .executable(name: "", targets: ["YourTargetName"])
    dependencies: [
        .package(url: "", .upToNextMinor(from: "14.0.0"))
    targets: [
        .target(name: "YourTargetName", dependencies: ["SocketIO"], path: "./Path/To/Your/Sources")

Then import import SocketIO.


Add this line to your Cartfile:

github "socketio/" ~> 14.0.0

Run carthage update --platform ios,macosx.

Add the Starscream and SocketIO frameworks to your projects and follow the usual Carthage process.

CocoaPods 1.0.0 or later

Create Podfile and add pod 'Socket.IO-Client-Swift':


target 'YourApp' do
    pod 'Socket.IO-Client-Swift', '~> 14.0.0'

Install pods:

$ pod install

Import the module:


import SocketIO


@import SocketIO;


Detailed Example

A more detailed example can be found here

An example using the Swift Package Manager can be found here



You can’t perform that action at this time.