In IOS simulator one can set the simulate location among the Apple pre-defined locations or add GPX file to Workspace to get all the countries(with lat and long).
If we set the location while the simulator starts and change the location at runtime will it affect the simulator or not?? or is there a way to change simulator's location at runtime so that location manager can handle the changes being made?
i'm using CLLocationManager's significantLocationChangeMonitoringAvailable method to track country change but simulator doesn't recognizing the change action being made.
Edit : Environment - Xcode 7.0.1 , ios9
Related
I always see the Apple inc as my current location on the map in my application's simulator. Can you help me to fix that?
You can change your simulator's location using the debug menu Debug > Location and choose a Custom Location, City Run, City Bicycle Ride or Freeway Drive.
Change custom location in simulator settings, or turn off simulating location in Debug->Location menu
I'm working on a project where it's very often necessary to change the user's location, of course I included all the necessary data to simulate the location from the very beginning of the project. Today Xcode does not pretend to be a custom location, I decided to try to simulate one of the standard locations (for example San Francisco), but when I launch the application on a real device, my real location is displayed on the real device. I tried to run the application on the simulator, but got the same result. I did a clean project, rebooted the real device (iPhone 7), rebooted Xcode but it did not give results. I read a few topics, but they all relate to the fact that the developers did not include the simulation of the location in the scheme. How can I fix this problem? Thank you.
Update: I've updated Xcode, now I'm using Version 9.1 (9B55), but this did not fix this bug. Sometimes (once a week approximately), Xcode refuses to simulate even standard locations from the list (for example San Francisco). Although the menu above the consoles shows that the location simulates.
Info.plist contains
<key>NSLocationWhenInUseUsageDescription</key>
<string>Turn On Location Services to allow App to show you Events near you.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Turn On Location Services to allow App to show you Events near you.</string>
<key>NSLocationUsageDescription</key>
<string>Turn On Location Services to allow App to show you Events near you.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Turn On Location Services to allow App to show you Events near you.</string>
Update 1: Xcode does not simulate the location only on a real device (iPhone 7), two weeks ago there was no such problem. When I call CLLocationManager to show an alert, this alert on the real device is not shown at all. I repeat, this problem does not always repeat, this can happen once a week, but no methods help to restore this possibility to a working state.
I got the same problem and here's my work around.
You know the Location Services is not working when you don't see the arrow on status bar when you request location. So just turn Location Services off and on again. I guess this is a bug.
Go to Phone Settings > Location Services... then turn it off and on.
Xcode > Debug > Location Simulation
Simulator > Debug > Location > Custom Location (this will take what you set from step 2.)
You should see the arrow on status bar when you request location. If not... try the steps again.
First of everything ... Warning! , read this (from apple):
You are required to include the NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUsageDescription keys in your app's Info.plist file. (If your app supports iOS 10 and earlier, the NSLocationAlwaysUsageDescription key is also required.) If those keys are not present, authorization requests fail immediately.
Anyway, i just suggest make a simple test.
Make sure that you set Allow Location Simulation on the Run Scheme for your Debug Build Configuration on your target-
Run your App, switch to the Map app on simulator (is is the rfirst time you use, make sure you accept allow location dialog). -
Change the location on the location icon on Xcode (see below), and check that the map move to that location-
If everything is ok, the map app must show selected location
If your app is not able to follow same behaviour, maybe you are missing something. Further reading:
About Location Services and Maps
CoreLocation Framework Reference
Cheers.
Is it possible to simulate heading in Xcode? My iOS project tracks the user location and heading while driving. But I cannot test it in simulator because simulator is unable to track heading (no compass hardware).
It is very inconvenient to go out in the field with actual device for each testing session.
I was thinking on the lines of getting a sample GPX file. Do you think GPX file will contain heading information and simulator will be able to use it?
I need to test the scenario where looking for near by places of US location while I am in India. I have GPX file having coordinates of US location but I do not have code access so how can I use this GPX file to make fake location?
In iOS Simulator Menu, go to Debug -> Location -> Custom Location. There you can set the latitude and longitude and test the app accordingly. This works with MapKit and also with CLLocationManager.
Is it possible to mock a location when using Core Location Manager like you can in Android? I want to do this so we can see simulated behaviors when a user is a different location.
If you are using at least Xcode 4.2 and iOS SDK 5+, you can launch your app and in the simulator you can click the debug menu, then click the location option, the click custom location. You can then enter a custom latitude and longitude. They also have options for Freeway Drive, City Bicycle Ride, and City Run these all emulate the device moving.
You can definitely simulate location on the device if you run from Xcode. After the app compiles, installs, and starts running, find the "Debug Bar" at the bottom of the window (or just above the Console, if you have that showing). There is a small "Location" icon that reveals a menu of locations, plus an option to load a GPX file if you want something more complex. You can also edit your build scheme to include a default location in the Run phase (i.e., for every run, not just when you set the location with the menu in the Debug bar).
One thing to note, if you're using your personal device and not a dedicated development device: the custom location Xcode sets persists even after you disconnect from Xcode. So if you leave your desk with your phone, you may find it still thinks it's in whatever location you simulated; restarting will clear this setting, and allow you to use your device normally.