views:

238

answers:

1

CLLocationManager on iPhone Simulator is supposed to fake Cupertino (isn't it?) but it does NOT, it fails with kCLErrorDomain Code=0 instead. LocationManager's delegate receives the message didFailWithError. This method is implemented to log the error and the console outputs the following:

Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

I was working on a real project when I ran into this problem but it is pointless to discuss my code because I downloaded "Locations" sample code (updated 2010-06-22 for iOS 4) from the dev center and the problem persisted.

The app is suposed to enable an "add" button when it receives the first location update so users can track their locations but it does nothing.

I added one (trivial) line to the implementation of didFailWithError to log the errors, if any. I get the error described above.

With Xcode 3.2.2 and targeting 3.1.3, I could get a fixed location (Cupertino) when running an older version of the "Locations" project.

Can somebody help?

Thanks.

+2  A: 

I've heard this reported before but never saw it myself until just now. I had Airport turned off on my MacBook since I was using ethernet. I turned on Airport and restarted the simulator and now it works.

You need Wi-Fi (Airport) enabled on your Mac for the simulator to report a position with Xcode 3.2.3.

progrmr
My Wi-Fi (Airport) is enabled and I still have the same problem. Maybe the simulator can't locate my Wi-Fi, do I need to register the location of my Wi-Fi at Skyhook? (See http://stackoverflow.com/questions/2140340/how-does-the-iphone-learn-new-wifi-locations-in-terms-of-using-them-for-location/2140499#2140499)
albertamg
I don't know, the simulator doesn't even use the WiFi, it always reports a fixed location in Cupertino anyway. Rather than spending a lot of time trying to fix it, you could just use this other solution: a [CLLocation simulator](http://stackoverflow.com/questions/802156/testing-corelocation-on-iphone-simulator) for use on the simulator.
progrmr
OK, so... "You need Wi-Fi (Airport) enabled on your Mac for the simulator to report a position with Xcode 3.2.3" but... "the simulator doesn't even use the WiFi, it always reports a fixed location in Cupertino anyway. ". Wooow. Is it a bug or what? Thank you anyway, I'll try this other solution you mention.
albertamg
Let me know if that works for you too. It's kind of hard to believe but I turned it on off 3 times and got the same results each time.
progrmr
This worked for me. I had the exact same problem over the last few days. Frustrating...I am on a iMac and turned on the AirPort...walla it location was updating properly again.
Steven Dorfmeister
I am also having the same issue on my MacBook, I tried to turn On / Off Airport. Even restarted didn't seem to fix the issue. :( Has anybody found a solution ?
Tharindu Madushanka
I ended up writing my own [CLLocationManager simulator class](http://github.com/progrmr/CLLocationManager-simulator) so I could do more testing on the iPhone simulator. You can use that if you can't get the iPhone simulator to give you any location.
progrmr
I think it could be the problem with 4.x CL framework, which has its default location(infinite loop, CA) replaced by error code.
Ameya