Browse and Resolve Bonjour Services on iOS

Jan 3, 2017

This is a very quick post.

In one of my current projects I wrote a macOS app that runs an embedded HTTP server and publishes itself as a Bonjour service. This can be easily done with an awesome library called CocoaHTTPServer. And from an iOS app that works with this macOS app, I need to browse available Bonjour services in current network and resolve their IP addresses and ports.

There’s no much resources on internet about this. Apple has some example code like BonjourWeb, but I like examples that have been reduced to their minimum essential, so I am writing this for my future reference, and for others who might need it.