Accidentally overwrote iPhone device location via Xcode - ios

So I'm working on a location-based iPhone app. I'm mainly testing on the iOS simulator, and as such using the Core Location Simulation. All good - I can pretend to be in New York or San Francisco or wherever.
Then I move to testing my app on my iPhone, with that checkbox still enabled. I go for a walk (in, like, the actual real world), pull out Google Maps, and realise that my actual, not-simulator iPhone is using a simulated location. In this instance my iPhone is stuck thinking that it's in London (where I live), but right central in Picadilly Circus, not where I am.
I get home, open up Xcode, and to make sure I've nailed down the cause (rather than just a weird GPS bug etc), change the 'default location' to Johannesburg. Unplug my phone, open Google Maps (and Foursquare, to be sure), same deal. Stuck in Johannesburg.
So it's definitely this panel here that's borked my phone, but I can't figure out how to reset it.
Things I've tried that don't seem to work:
changing 'default location' to 'none' & rerunning
disabling 'allow location simulation' & rerunning
So it seems once you've given your iPhone an arbitrary location to pretend to be in, just disabling that doesn't fix it.
Any ideas? I'm going travelling in a few days and really need my GPS to work!

While you have your device connected to the debugger there is a little button at the top of the debug panel. Right here:
Click on that and you can select 'don't simulate location', exit the app, and I think you'll be good to go.
I'm a little foggy too on how that relates to the location defined in the scheme and the location set in the simulator. I usually find it easier to set a location in the simulator itself rather than in the scheme (at least when testing in the simulator is possible) to avoid issues like this. In the simulator if you enter a location under 'Debug > Location > Custom Location...' while the simulator is on the springboard the location will persist between launches of the app and the simulator.

This has happened to me before, it was very strange and mysterious!
I don't remember how I fixed it, but: have you tried Reset Location & Privacy in the Settings app? If all else fails, I suspect Reset All Settings would maybe work.
As I try to remember, I think maybe hard rebooting the phone might also work (just turn it off, turn it back on).

just Reset Location & Privacy . turnoff location service . restart your phone .. turn on location service . try using google maps .. it work for me ..

The important step is the hard reset after resetting location settings. Not sure if you need to do anything in Xcode, but it is a good idea to select 'Don't simulate location'

Go back to Xcode (or whatever coding software you are using) and rerun the application, then select don't simulate location.

Goto Settings>Privacy>Location Services. Turn-Off Location Services. Restart the phone. Open Google maps. A popup will come to enable location service, click on the options given that will take you directly to Settings. If popup didn't appear in Google Maps, click on Mylocation button at the bottom. Enable Location services and get back to Google Maps. It re-enabled the real Location for me.

Go to Edit Scheme..., then select Run in left panel. In options, set Default Location under Core Location to None.

As suggested in this comment if you don't have Xcode handy, you can just power cycle the iPhone and this seems to be sufficient. You don't need to reset any settings. This worked this morning for my iPhone anyway, recalling it from a winter sojourn of Berlin.

Related

Android things DP6 Intent with android.provider.Settings.ACTION_SETTINGS does not work anymore

I was using the intent with android.provider.Settings.ACTION_SETTINGS to show the system settings screen from inside my app, to allow the user to configure certain details, like a bluetooth keyboard or adjust the timezone. This was working very well in the DP5.1.
But now in the DP6, the intent
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
Does not work anymore. No exception is logged in the console.
Any workaround on this?
THe option to install the apk after configuring the device with the IOT_LAUNCHER screen is not very practical for me. Because I want to deliver an image with a bundle, and my app will be started automatically, not allowing the user to see the IOT_LAUUNCHER screen.
Thanks.
In DP6 the Settings application is either deprecated or removed. APIs to modify the screen or time have been added.

Unable to simulate location on Xcode Version 9.0.1 (9A1004)

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.

simulate driving a route in device -iOS

I have a location based app that provides information for a driving trip in real time. I would like to test that app in device. How can I mock an entire trip without actually driving. I see a solution exists for Android through mock location apps, is there anything similar for iPhone as well? I would appreciate any pointer. Thanks for your help.
Yeah you can create a GPX file and load it in XCode.
When you start debugging an app in xcode on the bottom where the debugging logging is there is the breakpoint |> and || and there you will see a location icon (see image, black icon all the way to the right). Click that and it will give you option to add GPX file. Generate a GPX file of the route you want and when you load it the phone / simulator will automatically go through those points

Mock location when using iOS Core Location Manager

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.

Location services in mobile Safari: Don't Allow is saved...forever? Even with reset

My web app using location services worked fine until I started testing "Do not allow" use cases. Now an iPhone refuses to ever allow location services, even when I answer "OK" to "Safari" would like to use your current location.
To reproduce...
Using iPhone on iOS 5.1:
Load web page that makes location services calls (like http://smithsrus.com/geo.html)
Answer "Do not allow" when user permission prompt appears.
Reload page and answer "Do not allow" 2 more times.
Reload page and see "User Denied" without getting a prompt.
Go to "Settings->General->Reset->Reset Location Warnings" and tap "Reset Warnings".
Return to Safari, reload page and now see the user permission prompt.
Even if you answer "OK" the web page will still be Denied.
I kill and restart Safari, I delete all website data, I turn Location Services on and off, I even reboot, and still Safari refuses to actually Allow location services even when I say I want to.
Once you go through these steps, that web domain is dead to location services.
I'm running out of domains to test
I've searched many StackOverflow, Apple Developer and other sites for answers.
But it sure looks like a bug to me. Answering a prompt with "Allow" but getting denied must be a bug. After answering "Allow" the location services icon appears at the top of the screen briefly but then disappears, and in Location Services settings Safari appears with "On" and the gray icon next to it.
After trying a combination of reseting location warnings, turning on and off location services and closing and restarting the browser, I did manage to get one new error:
"The operation couldn't be completed. (kCLErrorDomain error 1.)" Sounds buggy.
I'd rather it be something silly I am doing, can anyone tell me?
I got it after about giving up and thinking there wasn't a solution. I managed to share my location on my iPhone 4s by doing the following:
Go to Settings -> General, scroll to the bottom and go to Reset-> Reset Location & Privacy.
The next time I opened my web-app to test its user location features, it worked like a charm. Hope this helps for all who have this problem.
The following steps solved it for me:
Close all tabs in safari with the domain in question open.
Close Safari (Hold home button and cross off).
Settings -> General -> Reset -> Reset Location Warnings / Reset Location & Privacy.
Open Safari and try again.
The trick (compared to mark's answer) is to make sure you close Safari fully. When I followed mark's answer, I got the prompt re-appearing for Safari itself, but not for my domain. After closing Safari then following mark's answer, I got 2 successive prompts, firstly for Safari, and then for my domain.
I was having the same issue caused by repeatedly hitting the "Do not allow" option.
The way I fixed this in my iPad 2 was to go into "Settings > General > Restrictions", then enable restrictions (have to enter passcode). From there I went into "Location" under the "Allow Changes" section and checked "Allow Changes" and made sure location services were on for all the listed apps. This seems to have reset it for me. After that I could go back into "General > Restriction" and disable restrictions again.
Hope this helps you!

Resources