Thank you for your detailed answer.
I have the following code in the LanDiscoveryService:
init() {
setupBrowser()
}
func startDiscovery() {
if browser == nil { setupBrowser() }
if browser!.state == .ready { return } //Already running
browser!.start(queue: DispatchQueue.main)
}
func stopDiscovery() {
browser?.cancel()
browser = nil
}
If I now add a browser?.cancel() call at the end of init() I indeed get the exact same crash, so it seems that stopDiscovery() was called before startDiscovery(), which would set the queue. I'm uncertain how this can happen in my code, or why I initialised the browser in init(), so I've plenty of options to explore now to resolve this crash!
Many thanks!