NWPathMonitor

I am using NWPathMonitor and it works perfectly at device but Apple is complain at simulator. I did bellow code to always returns true at simulator environment

   @objc var isOnline: Bool {
    #if targetEnvironment(simulator)
        true 
    #else
        hasWifi || hasCellular
    #endif
    }

Could someone help to identify what I did wrong?

Thanks in advance.

??🧐

When testing any type of network behavior it is always best to do in on a real device instead of a simulator. This gives you the most realistic view of what will happen in a production environment. From there you should be able to remove your environment conditional statement and focus on the available interfaces on the physical device.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
NWPathMonitor
 
 
Q