Contents

brightdigit/SublimationBonjour

Use Bonjour for Sublimation for automatic discovery of your Swift Server.

Requirements

Apple Platforms

  • Xcode 16.0 or later
  • Swift 6.0 or later
  • iOS 17 / watchOS 10.0 / tvOS 17 / macOS 14 or later deployment targets

Linux

  • Ubuntu 20.04 or later
  • Swift 6.0 or later

Installation

To integrate SublimationBonjour into your app using SPM, specify it in your Package.swift file:

let package = Package(
  ...
  dependencies: [
    .package(url: "https://github.com/brightdigit/SublimationBonjour.git", from: "1.0.0")
  ],
  targets: [
      .target(
          name: "YourServerApp",
          dependencies: [
            .product(name: "SublimationBonjour", package: "SublimationBonjour"), ...
          ]),
      ...
  ]
)

Usage

Setting up your Server

Create a BindingConfiguration with:

  • a list of host names and ip address
  • port number of the server
  • whether the server uses https or http
let bindingConfiguration = BindingConfiguration(
  hosts: ["Leo's-Mac.local", "192.168.1.10"],
  port: 8080,
  isSecure: false
)

Create a BonjourSublimatory using that BindingConfiguration and include your server's logger. Then attach it to the Sublimation object:

let bonjour = BonjourSublimatory(
  bindingConfiguration: bindingConfiguration
)
let sublimation = Sublimation(sublimatory : bonjour)

You can also just create a Sublimation object:

let sublimation = Sublimation(
  bindingConfiguration: bindingConfiguration
)

Setting up your Client

On the device, create a BonjourClient and either get an AsyncStream of URL objects via BonjourClient.urls or just ask for the first one using BonjourClient.first():

let client = BonjourClient()
let hostURL = await client.first()

Documentation

To learn more, check out the full documentation.

License

This code is distributed under the MIT license. See the LICENSE file for more info.

Package Metadata

Repository: brightdigit/SublimationBonjour

Stars: 2

Forks: 0

Open issues: 1

Default branch: main

Primary language: swift

License: MIT

Topics: bonjour, bonjour-discovery, developer-tools, development-environment, server-side-swift

README: README.md