Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS 9 Error Domain=kCLErrorDomain Code=0 "(null)"

Code below should get current location. But above error is generated. Function didUpdateLocations never gets called.

Running this on a device (iPhone 5s)iOS 9.1. Info.plist has Required device capabilities and Privacy - Location usage description configured as shown in the attached image. Please help!

let locationManager = CLLocationManager()  override func viewDidLoad() {     super.viewDidLoad()     locationManager.delegate = self     locationManager.requestAlwaysAuthorization()     locationManager.requestLocation() }   func locationManager(manager: CLLocationManager,     didFailWithError error: NSError)      print(error.description) }  func locationManager(manager: CLLocationManager, didUpdateLocations       locations: [CLLocation]) {          print(“got location”) } 

Info.plist

like image 669
Tusshu Avatar asked Sep 12 '15 21:09

Tusshu


2 Answers

Please try this :

Go to :

  • Product -> Scheme -> Edit Scheme -> Options -> Allow Location Simulation must be checked and try providing a default location, don't leave it set to "none"

EDIT : As mentionned in the comments, also restart Xcode and you're done !

Hope this helps.

like image 118
H4Hugo Avatar answered Oct 13 '22 11:10

H4Hugo


In XCode 11.5 and up...

Open your Simulator:

Features => Location => CustomLocation

enter image description here

like image 22
Roberto Rodriguez Avatar answered Oct 13 '22 11:10

Roberto Rodriguez