Skip to content

apple/swift-matter-examples

Repository files navigation

Swift Matter Examples

Build a Matter accessory using Embedded Swift

Overview

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 (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

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

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.

Additional Resources

Getting Started

Documentation

For comprehensive tutorials with detailed instructions, please refer to the project documentation.

Requirements

Before running the examples, ensure you have the following tools available:

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.

Quick Start Guide

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.

  1. 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
  1. Configure the build system for your microcontroller.
$ idf.py set-target esp32c6
  1. 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.

Contributing to Swift Matter Examples

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.

Code of Conduct

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.

Contact information

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.