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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of watchOS

watchOS

Photo of communication

communication

Photo of DSLs

DSLs

Related news:

News photo

Apple Seeds Release Candidate Versions of watchOS 11.3, tvOS 18.3 and visionOS 2.3

News photo

Apple Seeds Third Beta of watchOS 11.3 to Developers

News photo

Apple Seeds Second Betas of watchOS 11.3, tvOS 18.3 and visionOS 2.3 to Developers