Swiftpack.co - tgu/RosSwift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by tgu.
tgu/RosSwift 1.3.6
ROS Robotic Operating System - Swift implementation of core client libraries and rosmaster. Based on roscpp.
⭐️ 54
🕓 5 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/tgu/RosSwift.git", from: "1.3.6")


ROS Robotic Operating System - Swift implementation of core client libraries. Based on roscpp.

RosSwift is a Swift implementation of ROS. It provides a Swift library based on Swift-NIO that enables Swift programmers to interface to ROS. It is tested on OSX and Linux (Raspberry Stretch, Ubuntu) and should also work on all platforms that are supported by Swift-NIO.

There are some unimplemented features, basic publishing, subscription, services and parameters should work.


Minimum SDK10.15 on OSX, also works on iOS14

Swift 5.9 on Raspberry, tested with Ubuntu 20.10

It can be necessary to allow arbitary loads in the Info.plist file for iOS and macOS



The package include msgbuilder to generate code for custom messages.


The package include roscore that is a swift implementation of the ros master. The master advertises its presense with Bonjour on Apple devices and with Avahi on Linux devices. A client initialization of Ros will search for the master unless the url is specified with remapping ros = Ros(name: "phone", remappings: ["__master":""]) or with the environment variable ROS_MASTER_URI

For service discovery in iOS Client app, add NSBonjourServices to your Info.plist



The following code snippet shows how to model a publisher

import Foundation
import RosSwift
import RosTime
import StdMsgs

let ros = Ros(argv: &CommandLine.arguments, name: "talker")
let n = ros.createNode()
guard let chatter_pub = n.advertise(topic: "/chatter", message: String.self) else {

var rate = Rate(frequency: 10.0)

var j : Int32 = 0
while ros.ok {
    chatter_pub.publish(message: "Hello \(j)")
    j += 1

The following code snippet shows how to model a simple listener

import RosSwift
import StdMsgs
import msgs

let ros = Ros(argv: &CommandLine.arguments, name: "listener")
let node = ros.createNode()
let imu = node.subscribe(topic: "/imu") { (msg: sensor_msgs.Imu) in
    print("accel: [\(msg.linear_acceleration)]")

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics