I'm testing an iOS app with the simulator in xCode 5.x. The root view is a UIWebView that loads an external URL. The external page requests geolocation information, but I cannot get it to work in the simulator. The prompt appears to share location info, but the external page is unable to receive them.
What am I missing?
-e
in iOS Simulator menu, go to Debug -> Location -> Custom Location. There you can set the latitude and longitude and test the app accordingly.
settings> system > developer options Find the option select mock location app Then select the app you downloaded from step 1.
If you're making a route, tap-and-hold on the map to drop place markers. Use the play button on the bottom corner of the map to enable the fake GPS setting. You can close the app and open Google Maps or another location app to see if your GPS location has been spoofed.
Step 11: When the restore is complete, open the Maps app on your iPhone and select the new location that you would like to use. Tap at the bottom of the screen to get more information about the new location and then select “Simulate Location” to begin using the new location.
+1 to @Farhan for a helpful tip. Here's what solved my problem:
There are two places where simulator location gets set:
I played with the Default Location setting in the scheme and it didn't work. Mine is currently set to "None" which is unclear as to whether that means there is no location data provided or whether it defaults to the location of the host machine.
In the simulator under Debug > Location, it was also set to none. I tried using some of the presets, but it still didn't work. What eventually made it start working for me is I changed it to "Custom location" and entered the latitude and longitude of where I am located. Only then did it start working correctly.
This post has some helpful screenshots of what I'm describing.
This is a handy tool for getting latitude and longitude.
Update The solution I described above still works, but in the project I'm currently working on it doesn't seem to retain the settings, so I have to keep re-selecting my custom location. This gets tedious, so I created a new preset location using gpx file. Turns out this is really easy. Just use this tool to generate the file and download it. Then when you edit the schema, under Default Location, choose the "Add GPX file to project..." (and select the file you downloaded). That's it. For whatever reason, this setting does seem to get remembered when I re-run the simulator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With