What's New


  • Allow dynamic WebSocket URLs, which can be useful when passing authorization parameters, for example. When connecting, Socket.system now takes a () -> URL parameter.

Phoenix channels client for Apple OS's

(macOS, iOS, iPadOS, tvOS, and watchOS)

A package for connecting to and interacting with Phoenix channels from Apple OSes written in Swift taking advantage of the built-in WebSocket support and Swift Concurrency.

The public interfaces of Socket and Channel are simple structs whose public methods are exposed as closures. The reason for this design is to make it easy to inject fake sockets and channels into your code for testing purposes.

The actual implementations of Phoenix socket and channel are PhoenixSocket and PhoenixChannel, but those are not available publicly. Rather, you can opt in to using them via the Socket.production(url:) factory.

Compatible with Phoenix channels vsn=2.0.0 only.


To use Phoenix, add a dependency to your Package.swift file:

let package = Package(
  dependencies: [
      url: "",
      from: "8.0.0"


import Phoenix

let socket = Socket.production(url: URL(string: "wss://")!)
await socket.connect()

let channel = await"room:123", [:])

let messagesTask = Task {
  for await message in channel.messages() {

let joinResponse = try await channel.join()

try await channel.send("one-off-message", [:])
let response = try await channel.request("message-needing-reply", [:])
try await channel.leave()



Using Xcode

  1. In your Terminal, navigate to the phoenix-apple directory
  2. Open the phoenix-apple directory using Xcode
  3. Make sure the build target is macOS
  4. Product -> Test

Using swift test

  1. In your Terminal, navigate to the phoenix-apple directory
  2. Run the tests using swift test


  • Swift Tools 5.8.0
View More Packages from this Author


Last updated: Fri Nov 24 2023 23:22:05 GMT-1000 (Hawaii-Aleutian Standard Time)