TIL when you see the error message

Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates.

All you need to do is surround the code that’s causing the problem with

DispatchQueue.main.async {
  // code
}

It pushes the problematic operations back onto the main thread.

Been fighting with this since yesterday afternoon. 

Special thanks to Paul at https://www.hackingwithswift.com/read/9/4/back-to-the-main-thread-dispatchqueuemain

It’s one of those things that’s so obvious when you know. I just wish I’d found Paul’s simple explanation much earlier.