I was thrilled to see swift-ros2 featured in What's new in Swift: November 2026 Edition on Swift.org. Reading it is also how I learned about these forums, so I signed up to introduce the project properly and hear what Swift developers think.
swift-ros2 is an open-source (Apache 2.0) Swift client library for ROS 2, the Robot Operating System used on research and industrial robots.
It lets a Swift program join a ROS 2 network directly as a real node, with no bridge process in between. An iPhone can stream its IMU and camera to a robot, a Mac app can watch a robot's topics, and a Linux service written in Swift can run alongside C++ and Python nodes.
import SwiftROS2
import CommonInterfaces
let context = try await ROS2Context(
transport: .zenoh(locator: "tcp/192.168.1.100:7447"), distro: .jazzy,
domainId: 123)
let node = try await context.createNode(name: "sensor_node", namespace: "/ios")
let pub = try await node.createPublisher(Imu.self, topic: "imu")
try pub.publish(Imu(
header: Header.now(frameId: "imu_link"),
linearAcceleration: Vector3(x: 0, y: 0, z: 9.81)))
let sub = try await node.createSubscription(Imu.self, topic: "imu")
for await msg in sub.messages { print("accel: \(msg.linearAcceleration)") }
What might interest Swift developers
- Swift-native API: async/await,
AsyncStreamsubscriptions,Sendablemessage types and structured concurrency. - Platforms: iOS/iPadOS 16+, macOS 13+, Mac Catalyst, visionOS, Linux (Ubuntu 22.04/24.04, x86_64 and aarch64), Windows 10/11, and Android API 28+ (Zenoh only).
- Two transports, one API: Zenoh (interoperates with
rmw_zenoh_cpp) and DDS (interoperates withrmw_cyclonedds_cpp). On Apple platforms it uses the upstreamrclstack by default, with a pure-Swift path as a fallback whererclisn't available. - Generated Swift types:
swift-ros2-genturns ROS interface definitions into Swift through a SwiftPM build plugin, and the common message packages (std_msgs,geometry_msgs,sensor_msgs,nav_msgs,tf2_msgs) come pre-generated. - Full ROS 2 feature set: topics, services, actions and parameters, verified against ROS 2 Humble, Jazzy, Kilted and Lyrical.
Packages (all under swift-ros2 GitHub org)
- swift-ros2: the runtime (nodes, publishers, subscriptions, services, actions, parameters)
- swift-ros2-rosidl: the message codec, protocols and code generator
- swift-ros2-common-interfaces: generated standard messages
Used in a shipping app
The library grew out of Conduit, my iOS app that turns Apple devices into ROS 2 sensor publishers. Conduit has passed 10,000 downloads, and it runs on swift-ros2 today.
In October I presented swift-ros2 and Conduit at ROS By-The-Bay, hosted by Intrinsic, with a live demo of iPhone, iPad and Mac joining a ROS graph alongside Linux nodes. The slides are here:
Feedback welcome
I'd especially love to hear from Swift developers on:
- whether the API feels idiomatic, particularly around concurrency,
- experience on Linux, Windows or Android,
- what you would build with Swift on a robot.
Thanks for reading!
Yutaka