CLLocationManager is slow getting location, Swift

From the documentation of requestLocation():

This method returns immediately. Calling it causes the location manager to obtain a location fix (which may take several seconds) and call the delegate’s locationManager(_:didUpdateLocations:) method with the result.

Source

So basically, everything is fine with your code, it's just how the framework is built.


When initializing your location manager, add startUpdatingLocation():

let manager = CLLocationManager()
 manager.delegate = self
 manager.requestWhenInUseAuthorization()
 manager.requestLocation()
 manager.startUpdatingLocation()

Without startUpdatingLocation() geo-location takes about 5 seconds, with it, the request executes nearly immediately.


Try setting the accuracy and use locationManager.startUpdatingLocation(). I do that, and get answer within a second (on the device).