A simple Homekit Accessory Protocol (HAP) starter project in Swift that uses Bouke Haarsma's excellent HAP package.
Install libsodium using Homebrew:
brew install libsodium
Install the necessary dependencies, e.g. using apt
:
sudo apt install openssl libssl-dev libsodium-dev libcurl4-openssl-dev libavahi-compat-libdnssd-dev
swift build -c release
.build/release/swift-hap-starter
To customise, edit main.swift
in the Sources/swift-hap-starter
subdirectory. Under macOS you might want to create an Xcode project for easier editing:
swift package generate-xcodeproj
open swift-hap-starter.xcodeproj
-
Older Swift 4.x, ARM-based Linux versions (e.g. for the Raspberry Pi) seem to have a bug that makes them crash.
-
The BlueSignals dependency package currently does not build under Ubuntu 18.04 against the Swift 4.2-CONVERGENCE toolchain (
error: converting non-escaping value to 'T' may allow it to escape
). -
The BlueCryptor dependency package currently only works with OpenSSL-1.0.x (not 1.1.x or newer). For older linux distributions, this may be the default, in which case you may want to
apt-get install libssl-dev libcurl4-openssl-dev
(instead oflibssl1.0-dev
, which is required for newer versions of Debian or Ubuntu).
This project would not be possible without the excellent Swift HAP library written by Bouke Haarsma and contributors.