Build a Matter accessory using Embedded Swift
This repository contains an example simple Embedded Swift application that implements a Matter smart light accessory and can be used from HomeKit. The examples use an ESP32-C6 or ESP32-C3 (RISC-V) microcontroller and build on top of the ESP-IDF and ESP-Matter SDKs.
Note
This repository is associated with WWDC24 session 10197: Go small with Embedded Swift.
Embedded Swift is a subset of Swift designed for constrained environments, such as embedded devices, kernel code, and other low-level systems. It includes most Swift language features, like generics, value and reference types, optionals, error handling, and more. Embedded Swift introduces the safety and expressivity of Swift to environments usually dominated by C or C++ code. To learn more, see A Vision for Embedded Swift.
Matter is an open standard for building smart home accessories, supported natively by many smart home ecosystems such as HomeKit. For more information about Matter, see the Matter documentation.
For comprehensive tutorials with detailed instructions, please refer to the project documentation.
Before running the examples, ensure you have the following tools available:
- Hardware:
- Software
Important
The examples are designed for an Espressif C6 Development Kit from both macOS and Linux host systems. Other configurations may work, but have not been tested.
Important
We highly recommend following the provided tutorials.
Ensure your shell has access to the tools listed above, see Get started on macOS or Get started on Linux with Docker for additional setup instructions.
- Clone the repository and navigate to one of the examples.
$ git clone https://github.com/apple/swift-matter-examples.git
$ cd swift-matter-examples/smart-light
- Configure the build system for your microcontroller, the
smart-light
example should also be runnable onesp32c3
.
$ idf.py set-target esp32c6
- Build and deploy the application to your device.
$ idf.py build flash monitor
Explore the implementation, see Explore the LED Blink example and Explore the Smart Light example for guided walkthroughs.
This repo is intended to demonstrate use of Embedded Swift for different applications, using Matter as an example. PRs demonstrating ways to adapt Swift's language or tooling to this application are welcome. It is not intended to be a full-featured Matter SDK so please do not raise PRs to extend the Matter Swift overlay to new areas.
Like all Swift.org projects, we would like these Embedded Swift example projects to foster a diverse and friendly community. We expect contributors to adhere to the Swift.org Code of Conduct.
The current code owners of this repository are Kuba Mracek (@kubamracek), Rauhul Varma (@rauhul), and Philippe Hausler (https://github.com/phausler). You can contact them on the Swift forums via the handles @kubamracek, @rauhul, and @Philippe_Hausler.
In case of moderation issues, you can also directly contact a member of the Swift Core Team.