Get Started with Embedded Swift on ARM and RISC-V Microcontrollers
Article Summary
Swift just jumped from iOS apps to microcontrollers. The Swift team launched example projects showing how to write firmware for ARM and RISC-V chips using a new experimental compilation mode.
The Swift team released a repository of sample projects demonstrating Embedded Swift, an experimental compilation mode that lets developers write firmware for microcontrollers. The mode disables features like runtime reflection and ABI stability to produce standalone binaries suitable for constrained embedded environments while keeping Swift's familiar syntax.
Key Takeaways
- Embedded Swift targets ARM and RISC-V microcontrollers for IoT and electronics projects
- Disables reflection and existentials but maintains idiomatic Swift syntax developers know
- Examples cover STM32, Raspberry Pi Pico, Nordic, and ESP32 boards
- Supports standalone Swift code and bridges to vendor SDKs
- Available only in nightly toolchains, not yet in stable releases
Swift can now compile to bare metal firmware for popular microcontroller boards while preserving most of the language features developers rely on.
About This Article
Swift on microcontrollers had to balance language features with hardware limits. Runtime reflection, ABI stability, and existentials needed to go so the compiler could produce standalone binaries for firmware.
Apple's compiler team, led by Kuba Mracek, built an experimental Embedded Swift mode that turns off heavy features while keeping Swift's familiar syntax. The approach is documented in the formally accepted Embedded Swift Vision Document.
The swift-embedded-examples repository now has Embedded Swift working on STM32, Raspberry Pi Pico, Nordic Semiconductor, and ESP32C6 boards. Community members have added support for different build systems and vendor SDKs.