Testing CoreLocation on iPhone Simulator
Thanks for the great feedback, it has prompted me to find a robust solution.
All the code can be found here:
http://code.google.com/p/dlocation/
It is very messy but as I use it it will be become much better.
The solution was to subclass CLLocationManager
and define a new delegate @protocol
, called DLocationManagerDelegate
.
It is designed to be a simple drop-in replacement for CLLocationManagerDelegate
that compiles down to a very thin layer when deployed on an actual device.
When running on the device it will return data as normal using CoreLocation
, but in the simulator it will read latitude and longitude from a text file (defined in the DLocationManager.h file).
I hope this helps, the implementation is on the simple side and you have to startUpdatingLocation
and stopUpdatingLocation
to update the display.
Comments and feedback will be gratefully received.
Core Location in iPhone Simulator 3.2 (iPad)
Yes, see this question which has several good answers to this.
EDIT - I eventually decided to write my own CLLocationManager simulator for testing on the iPhone simulator. It's located on github here if you want to use it.
CoreLocation enabled in simulator
The only way I know of to simulate core location tracking on a simulator is by choosing one of the location options available in debug tab of the simulator.
Testing location distance on iPhone simulator
Distance is a question of having two CLLocation
objects. Then you can simply call:
[location1 distanceFromLocation:location2]
That'll give you the distance.
If you need to create a location (from a CLLocationCoordinate2D
, for example), you just initialize it with latitude and longitude.
[[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
If you mean that you wish to have the simulator simulate a specific location, you can create a GPX file and add it to your project. The GPX file format is very simple:
If you add multiple wpt
items, the simulator will simulate motion between them.
CLLocationManager on iPhone Simulator fails with kCLErrorDomain Code=0
CLLocationManager
started to work as expected again on the iOS Simulator 5.0.
In my experience, it used to fail consistently with kCLErrorDomain Code=0
on the iOS Simulator 4.0 through 4.3. Turning the airport on and connecting to a Wi-Fi, as suggested by the other answers, did not help in my case. However, I would like to thank everybody for their answers. I simply worked around this issue by testing all the Core Location code on a device.
Recently I upgraded to XCode 4.2 (from XCode 3.2.6) and the iOS Simulator 5.0 that comes with it, and as a result of that, I noticed that the CLLocationManager
started to work as expected again. When selecting an older simulator in XCode 4.2, it keeps failing; which points to the simulator as the one to blame.
Testing current location in Iphone simulator
I'm not sure what the problem is or what you hope to achieve. You can add a custom annotation to a specific location specifying the coordinate using CLLocationCoordinate2DMake( , );
If you are interested in your current address, use CLLocationManager for the specific location. On the simulator on a MKMapView your current location is always Infinite Loop at San Jose, California.
Related Topics
Drop-Down List in Uitableview in iOS
Ibeacon: Didrangebeacons Stops Getting Called, Must Reset Device for It to Work Again
Xcode 8 - Ib Designables - Failed to Render and Update Auto Layout Status, the Agent Crashed
How to Release a Cgimageref in iOS
Round Top Corners of a Uibutton in Swift
Uiscrollview: Paging Horizontally, Scrolling Vertically
How to Set Up Push Notifications in Swift
How to Show a Custom Uimenuitem for a Uitableviewcell
Uigraphicsgetimagefromcurrentimagecontext Memory Leak with Previews
How to Create an Empty Application in Xcode Without Storyboard
Wrong Color in Interface Builder
Nsurlconnection Sendasynchronousrequest Can't Get Variable Out of Closure
How to Draw a Line Programmatically from a View Controller
Method Overloading in Objective-C
How to Delete Wkwebview Cookies
Cocoapods - 'Pod Install' Takes Forever