home / skills / nonameplum / agent-skills / programming-swift-embedded

programming-swift-embedded skill

/programming-swift-embedded

This skill provides comprehensive Embedded Swift documentation for microcontrollers and bare-metal development, guiding setup, usage, and advanced topics for

npx playbooks add skill nonameplum/agent-skills --skill programming-swift-embedded

Review the files below or copy the command above to add this skill to your agents.

Files (27)
SKILL.md
5.2 KB
---
name: programming-swift-embedded
description: Provides the complete Embedded Swift documentation for developing on microcontrollers, embedded systems, and baremetal applications.
---

# Embedded Swift

Embedded Swift is a compilation and language mode that enables development of baremetal, embedded and standalone software in Swift

## Documentation Structure

### Getting Started

- **Introduction to Embedded Swift** ([GettingStarted/Introduction.md](GettingStarted/Introduction.md)): Write Swift code for microcontrollers, embedded systems, and bare-metal applications
- **Language subset** ([GettingStarted/LanguageSubset.md](GettingStarted/LanguageSubset.md)): Details of the Embedded Swift language subset compared to full Swift
- **Install Embedded Swift** ([GettingStarted/InstallEmbeddedSwift.md](GettingStarted/InstallEmbeddedSwift.md)): Get the tools needed to use Embedded Swift

### Guided Examples

- **Getting started with Embedded Swift** ([GettingStarted/WaysToGetStarted.md](GettingStarted/WaysToGetStarted.md)): Possible directions to explore to start using Embedded Swift
- **Try out Embedded Swift on macOS** ([GuidedExamples/macOSGuide.md](GuidedExamples/macOSGuide.md)): Tutorial for building a simple program for your host OS with Embedded Swift
- **Raspberry Pi Pico Blink (Pico SDK)** ([GuidedExamples/PicoGuide.md](GuidedExamples/PicoGuide.md)): Tutorial for targetting a Raspberry Pi Pico as an embedded device that runs a simple Swift program
- **Baremetal Setup for STM32 with Embedded Swift** ([GuidedExamples/STM32BaremetalGuide.md](GuidedExamples/STM32BaremetalGuide.md)): Program a STM32 microcontroller directly with low-level Swift code

### Using Embedded Swift

- **Basics of using Embedded Swift** ([UsingEmbeddedSwift/Basics.md](UsingEmbeddedSwift/Basics.md)): Basic information for using Embedded Swift in typical embedded projects
- **Strings** ([UsingEmbeddedSwift/Strings.md](UsingEmbeddedSwift/Strings.md)): How to enable full Unicode-compliant string support in Embedded Swift
- **Conditionalizing compilation for Embedded Swift** ([UsingEmbeddedSwift/ConditionalCompilation.md](UsingEmbeddedSwift/ConditionalCompilation.md)): How to share code between Embedded Swift and full Swift using conditional compilation
- **Libraries and modules in Embedded Swift** ([UsingEmbeddedSwift/Libraries.md](UsingEmbeddedSwift/Libraries.md)): Understand the library setup and linkage model of Embedded Swift
- **External dependencies** ([UsingEmbeddedSwift/ExternalDependencies.md](UsingEmbeddedSwift/ExternalDependencies.md)): What external system dependencies should you expect from Embedded Swift compilations
- **Existentials** ([UsingEmbeddedSwift/Existentials.md](UsingEmbeddedSwift/Existentials.md)): Restrictions on existentials ("any" types) that apply in Embedded Swift
- **Non-final generic methods** ([UsingEmbeddedSwift/NonFinalGenericMethods.md](UsingEmbeddedSwift/NonFinalGenericMethods.md)): Restrictions on unbound generic methods that apply in Embedded Swift

### Build System Support

- **Integrate with Bazel** ([BuildSystemSupport/IntegrateWithBazel.md-wip](BuildSystemSupport/IntegrateWithBazel.md-wip)): *(Work in Progress)*
- **Integrate with CMake** ([BuildSystemSupport/IntegrateWithCMake.md-wip](BuildSystemSupport/IntegrateWithCMake.md-wip)): *(Work in Progress)*
- **Integrate with Make** ([BuildSystemSupport/IntegrateWithMake.md-wip](BuildSystemSupport/IntegrateWithMake.md-wip)): *(Work in Progress)*
- **Integrate with SwiftPM** ([BuildSystemSupport/IntegrateWithSwiftPM.md-wip](BuildSystemSupport/IntegrateWithSwiftPM.md-wip)): *(Work in Progress)*
- **Integrate with Xcode** ([BuildSystemSupport/IntegrateWithXcode.md-wip](BuildSystemSupport/IntegrateWithXcode.md-wip)): *(Work in Progress)*

### SDK Support

- **Integrating with embedded platforms** ([SDKSupport/IntegratingWithPlatforms.md](SDKSupport/IntegratingWithPlatforms.md)): Understand the common patterns and approaches for integrating Swift with existing embedded systems
- **Baremetal use of Embedded Swift** ([SDKSupport/Baremetal.md](SDKSupport/Baremetal.md)): Programming without an SDK for maximum control and minimal size
- **ESP IDF** ([SDKSupport/IntegrateWithESP.md-wip](SDKSupport/IntegrateWithESP.md-wip)): *(Work in Progress)*
- **Raspberry Pi Pico SDK** ([SDKSupport/IntegrateWithPico.md](SDKSupport/IntegrateWithPico.md)): Setting up a project that can seamlessly use C APIs from the Pico SDK.
- **Zephyr RTOS SDK** ([SDKSupport/IntegrateWithZephyr.md](SDKSupport/IntegrateWithZephyr.md)): Integrating Swift with Zephyr RTOS for embedded systems development

### Compiler Development and Details

- **ABI of Embedded Swift** ([CompilerDetails/ABI.md](CompilerDetails/ABI.md)): Understanding the different ABI (Application Binary Interface) for Embedded Swift
- **Implementation Status** ([CompilerDetails/Status.md](CompilerDetails/Status.md)): Implementation status of compiler and language features in Embedded Swift, comparison to standard Swift

## Usage Notes

- Documentation is organized progressively from getting started to advanced topics
- Start with the Introduction or Getting Started section
- Consult specific guides for detailed information

## License & Attribution

This skill contains content converted from DocC documentation format.

Overview

This skill delivers the complete Embedded Swift documentation set for building baremetal, microcontroller, and embedded system applications in Swift. It organizes progressive guidance from getting started through compiler internals, SDK integration, and platform-specific examples. The content is tailored to help engineers adopt a constrained Embedded Swift language mode and toolchain for small, standalone targets.

How this skill works

The skill exposes structured docs covering installation, the Embedded Swift language subset, and guided examples for targets like Raspberry Pi Pico and STM32 baremetal. It explains build-system integration (SwiftPM, CMake, Bazel, Make, Xcode work-in-progress), SDK patterns, and low-level compiler/ABI details. Users can follow step-by-step tutorials, reference constraints (existentials, generics), and learn best practices for linking with C SDKs and RTOSes.

When to use it

  • When porting Swift code to run on microcontrollers or baremetal targets
  • When you need a minimal Swift runtime and language subset for constrained devices
  • When integrating Swift with existing embedded SDKs like Pico or Zephyr
  • When designing or debugging Embedded Swift ABIs and compiler behavior
  • When setting up build pipelines for embedded Swift projects

Best practices

  • Start with the Introduction and Getting Started guides before attempting platform ports
  • Follow the language subset rules to avoid unsupported Swift features on embedded targets
  • Use conditional compilation to share code between host and embedded builds
  • Prefer explicit, minimal runtime and library dependencies to reduce binary size
  • Test on reference examples (Pico blink, STM32 baremetal) before targeting custom boards

Example use cases

  • Build a simple blink demo for Raspberry Pi Pico using the Pico SDK with Swift
  • Develop a baremetal STM32 application using low-level Swift startup and peripheral code
  • Integrate Swift with Zephyr RTOS to prototype embedded application logic
  • Conditionally compile shared networking code to run on macOS for testing and on-device for deployment
  • Investigate ABI and compiler constraints when porting libraries to Embedded Swift

FAQ

Do I need a custom Swift toolchain to use Embedded Swift?

Yes. Embedded Swift requires a compilation mode and toolchain that target baremetal and constrained platforms; follow the Install Embedded Swift guide for the required tools.

Can I use all Swift language features on embedded targets?

No. Embedded Swift documents a language subset and specific restrictions (existentials, non-final generic methods, etc.). Use the Conditional Compilation guide to maintain cross-target code.