Get the latest tech news
DSLs for Safe iOS/WatchOS Communication
I'm currently writing an Apple Watch counterpart app for Podcatcher. The Watch Connectivity framework that iOS apps use to communicate with watchOS apps offers a limited API for communication: you can either send untyped dictionaries or arbitrary byte strings between the two.
One approach you can take is to encode shared structs as JSON and pass them around as byte strings, manually writing all the boilerplate code to ensure that a response to a certain message decodes to the right type, and so on. This takes advantage of Noise's and to generate Swift enums and structs that can be serialized and deserialized to and from byte strings. That short define-watch-rpcs declaration from the first code snippet saves me a lot of manual typing and error-prone wiring up of things.
Or read this on Hacker News