I'm testing network loss handling in my app on the simulator.
- Turning WiFi OFF triggers
pathUpdateHandler
with .unsatisfied status. - Turning WiFi back to ON triggers
pathUpdateHandler
with .unsatisfied status again.
I noticed that pathUpdateHandler
is triggered right after I enabled WiFi, but before WiFi actually connects to the network. When the laptop is actually connected to the WiFi network - pathUpdateHandler
isn't triggered, so my app stays in "offline" mode permanently.
networkMonitor.pathUpdateHandler = { [weak self] path in
guard let self = self else { return }
DispatchQueue.main.async {
if path.status == .satisfied {
self.status = .connected
} else {
print(path.unsatisfiedReason)
self.status = .disconnected
}
}
}
monitor.start(queue: queue)
networkMonitor
is retained by my DIContainer
You should feel free to file a bug about this but the fundamental issue here is this:
I'm testing network loss handling in my app on the simulator.
Testing this sort of thing in the simulator is pointless; tests like this need to be run on a real device. The issue is that that simulator is using the macOS networking stack, and so it’s networking behaviour tracks macOS, not iOS.
ps If you do end up filing a bug, please post your bug number, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"