I have an app that does geofencing. When I run it in the Simulator (Xcode 8.3.3 and Xcode 9), everything seems to work with the exception that my CLLocationManager didEnterRegion is never called.
It is called just fine when I run the app on my iPhone, either out in the real world (entering a region) or in Xcode via location simulation.
Any idea why this would be?
One difference I've discovered is that the simulator only supports monitoring location when in use, so I had to set things up so I had had both permission strings in my plist file, but other than that I'm stumped.
Since I'm not providing code (it's way too complex and distributed in my app), let me note what is working in the simulator:
In my app's scheme, I have 'Allow Location Simulation' checked and I have a have a few .gpx files added for locations I'm monitoring. I have a default location set.
My location manager delegate is being called when I start up. I get .authorizedWhenInUse in the Simulator and .authorizedAlways on the phone.
locationManager(:didUpdateLocations:) is being called when the location changes.
When didUpdateLocations is called, I do the following:
for r in manager.monitoredRegions { if let cr = r as? CLCircularRegion { if cr.contains(location.coordinate) { log.debug("Am in the region!") } else { let crLoc = CLLocation(latitude: cr.center.latitude, longitude: cr.center.longitude) log.debug("distance is: \(location.distance(from: crLoc))") } }and it works. So my regions are being monitored and my location is where I think it should be.
Finally, my locationManager delegate's monitoringDidFailFor and didFailWithError are NOT being called. Not that they've never been - they have during development, but not now.
So I'm stumped. Again, it works fine on the phone and not in the simulator.
What am I doing wrong?