Open Source

Working at LIFX I was very active in the third-party developer community, helping to provide direct support and improved documentation to developers. I have contributed to Open Source libraries that work with LIFX lights in C# and on iOS. I have also open sourced a new implementation of the LIFX protocol parser in Swift.

Swift LIFX Protocol

The Swift LIFX Protocol contains code to parse and serialise all public LIFX messages. This makes it much easier for a third-party developer to build an app on Mac or iOS that can communicate directly with LIFX lights as they can easily create the binary messages to communicate with the devices. The protocol implementation handles a lot of the validation around the protocol including throwing errors when array size limits are exceeded etc. The API has been optimised for ease-of-use. A lot of the code in the protocol is generated from an internal application written in golang, which runs a single source of truth through templates to produce different implementations of the protocol. However, the swift version is the first of these to be made open source.

Swift ByteBuffer

The Swift ByteBuffer is a library used internally by the Swift LIFX Protocol implementation. Because the LIFX protocol utilises bit fields it was difficult to work with deserialising messages without a lot of bitmasking and shifting. The ByteBuffer simplifies this whole process and allows you to read out arbitrary data types out of a buffer using a specified number of bits. The ByteBuffer can also be used to write data to bytes. It can also be useful for other data operations related to byte order.

Swift ByteBuffer GitHub Repo

RxRouter

RxRouter is a framework for separating the navigation logic in an iOS app from the boilerplate of instantiating ViewControllers. This separation allows for more dynamic behaviour e.g. where the style of navigation might differ on iPad vs. iPhone without having to making changes to the underlying navigation. RxRouter is based on the three separate roles of 'Router', 'Coordinator', and 'Transitioner'. The Router is effecitvely pure logic and makes decisions about what navigation should take place. The Coordinator connects the Transitioner and Router together and is responsible for instantiating the ViewControllers. Lastly, the Transitioner is a generalised component that handles presentation of ViewControllers i.e. push in NavigationController or modal presentation. The Transitioner being separate means that the Coordinator is not necessarily coupled to a specific style of presentation. RxRouter is effectively an implementation of the Coordinator Pattern but is tailored to iOS navigation patterns.