Swiftpack.co - doHernandezM/SwiftyPi as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by doHernandezM.
doHernandezM/SwiftyPi v0.1
Swift based Raspberry Pi pin controller.
⭐️ 1
🕓 48 weeks ago
iOS macOS
.package(url: "https://github.com/doHernandezM/SwiftyPi.git", from: "v0.1")


This package is heavily based on and would not be possible without SwiftyGPIO. This is not meant to be a replacement, more like an extra layer to make using Swift with rPi devices such as buttons, relays, LEDs, UART and LCDs easier. Support is currently limited as this is a hobby. Since SwiftyPi is made to work in conjunction with ApusRupus I have decided against implementing a delegate. You will have to actively poll each device in a loop for state. I may change this to implement the timer better.

See SwiftyPi.DocC / In source comments


  • Same as SwiftyGPIO
      • Swift 5.3+

~~Funtionality options:

I recommend visiting SwiftyGPIO and getting familiar with this API first. However, the goal to eventually be able to call many devices, so eventually SwiftyDevice is all you need to worry about.

~~Do this:

.package(url: "https://github.com/doHernandezM/SwiftyPi.git", ._exactItem("0.1.30")),


  • ~~Use this to create a GPIO pin using the SwiftyGPIO pin naming convention, i.e. "P4" for pin 4.
public init(gpioPinName: String, theType: SwiftyPiType)

~~Device actions

  • ~~Each device has an action that can be run at a certain time depending on type and protocol. This is a simple block that returns nothing, of the type:
public typealias CompletionHandler = () -> Void
  • ~~To set this action assign a block( () -> Void ) to a device's handler. This block will be called during the device's "action" event.
public var handler: CompletionHandler? = nil
  • ~~To set or get a device's state, or pin value, use:
public var bool: Bool
public var int: Int
public var mode: SwiftyPiMode


Stars: 1
Last commit: 40 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.


Release Notes

45 weeks ago

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