Testing custom location with simulator - ios

I just spent the last hour searching - thinking that there has to be an answer - and didn't find much, so I'm asking here.
I'm trying to get the sample app Regions to trigger enter and/or exit regions updates via the simulator. I'm familiar with setting a specific latitude and longitude with Debug > Location > Custom Location but that doesn't seem to do much, although it does seem to work in the LocateMe sample app. At this point I don't know if the problem is a limitation of the iOS Simulator or of the way the sample app handles region detection (I'm still rather new to iOS).
I've come across the FTLocationSimulator but I wonder if that's going to help (especially since it seems to mimic the ability to set Custom Locations via the Simulator).
There also doesn't seem to be much in terms of Apple documentation regarding the iOS Simulators ability to set Custom Locations.

Add a GPX file to your project and add waypoints to it. When your app is running under simulation use the Simulate Location feature of XCode (the little way-arrow sitting on the debug bar at the bottom) and choose your GPX file. XCode will then start supplying coordinates to your app.
Example GPX file contents:
<?xml version="1.0"?>
<gpx>
<wpt lat='33.749272' lon='-84.388261'><name>Atlanta, Georgia</name></wpt>
<wpt lat='42.7335' lon='-84.5467'><name>Lansing, Michigan</name></wpt>
<wpt lat='32.361667' lon='-86.279167'><name>Montgomery, Alabama</name></wpt>
<wpt lat='38.576667' lon='-92.173611'><name>Jefferson City, Missouri</name></wpt>
<wpt lat='41.590833' lon='-93.620833'><name>Des Moines, Iowa</name></wpt>
</gpx>
Note that the simulator will 'connect the dots' between two waypoints (in the example above it will generate locations along a line between Atlanta, Georgia and Lansing, Michigan.

This works for me:
Go into the Settings application in the simulator
Navigate to General -> International -> Region Format -> (Choose a region)
Specify a region
Hope this helps!

Related

Does iOS Simulator not have Current Location

I'm messing about with React Native, and I came across this other post: Permission Denied Geolocation React Native. I wanted to append another question onto that post, but I do not have a high enough ranking to make comments.
My question is, does the iOS simulator not have the current location ability automatically? I know that macOS apps in Xcode have full networking and geolocation abilities, thus I don't need to specify a location when using CLLocationManager. I'm trying to understand the reasoning and limitations behind the iOS simulator; specifically as to why it would not simply behave like any other VM and just use the host's wifi for basic network and location settings? Why would I need to specify a location upon simulator startup?
Thanks in advance!
As far as I know, apple does not support 'real' gps through the iOS simulator, but it does provide you with a variety of other options as you can see on this screenshot I made for you:
Screenshot
Hope that helps!
To get the current location in simulator you have to add GPX file in your project.
Project->New file -> iOS->Resource->select GPX file
Here is a simple GPX file . You just change the name and lat/long.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gpx
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
version="1.1"
creator="gpx-poi.com">
<wpt lat="lat" lon="long">
<name>YourLocation</name>
</wpt>
</gpx>

Mock GPS location on IOS device

My IOS app is location depend. I have to test the app by setting different fake GPS locations on real IOS 9.3.1 devices. I searched Fake location app but nothing worked as expected. Most of the app are related to take photo and share on fb or twitter with fake location. These app are not changing the device gps location
My client need to test the app in different location. He is able to do the same in android and expecting the same from IOS. Any idea apart from debug mode.
Is it possible to set fake location in IOS real device.
You can do this if you have the device connected to the computer in debug mode through XCode. Go to Debug -> Simulate Location and select one of the pre-existing locations.
Alternatively, you can add your own GPX file to the project simulate any other custom location. Your GPX file would look similar to this, you would just need to update the latitude and longitude.
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.0">
<wpt lat="46.57638889" lon="8.89263889">
<name>LAGORETICO</name>
</wpt>
</gpx>
See this link for more details on how to write your own GPX file.
This link, although slightly outdated, has a great example of how to do this from start to finish.

How can I change the track for the freeway drive in simulator?

I need to debug the use location for the particular track. I have checked the freeway drive that gives the track in Cupertino. I want to test the user track in my city. is there any way to test and debug.
Thanks.
Yes, it is - GPX FILES
GPX is a standard file format used for expressing GPS locations. The format for GPX files that Xcode looks for is fairly straightforward:
<gpx>
<wpt lat="38.897678" lon="-77.036517"></wpt>
</gpx>
create and add this file to Xcode
Once the app is running on your device, go to Product > Debug > Simulate Location, and select the last option in the list that says “Add GPX File to Project…”, then select the Your.gpx file we just created
More info here:
http://blackpixel.com/blog/2013/05/simulating-locations-with-xcode.html
http://www.doubleencore.com/2013/04/using-xcode-to-test-location-services/
http://www.cardinalsolutions.com/cardinal/blog/mobile/2013/02/testing_a_location-a.html

How to create GPX for IOS Simulator with Altitude and Court

How can I (or can I) create a GPX file that will run on the IOS simulator and provide course and altitude information?
I have added tags in the hope they might give altitude but no joy there.
The larger issues I am having in dealing with the simulation of locations include:
1. The GPX documentation gives no semantic information;
2. The I am unaware of any documentation on how the IOS simulator responds to GPX files;
3. Many of the links to sites from this board for creating GPX files seem to create files with tags that the IOS simulator seems to ignore.
Thanks

How to set fake GPS location on IOS real device

Currently I have to test app and set the different fake GPS locations on real IOS 7 devices. On Android I use 'My Fake Location'. Unfortunately, I didn't find the same app for IOS 7.
Any ideas to solve my problem?
When running in debug mode you can use the little arrow button in the debug area (Shift+Cmd+Y) in Xcode to specify a location. There are some presets or you can also add a GPX file.
You can generate GPX files here manually: http://www.bikehike.co.uk/mapview.php
(from answer: https://stackoverflow.com/a/17478860/881197)
Create a .GPX file with xcode, then specify your coordinates and when your device connected, hit the little arrow button and select your .GPX file.
You can create multiple files and add lots of coordinates to single .GPX file in order to make some kind of route.
Of course ios7 prohibits creating fake locations on real device.
For testing purpose there are two approches:
1) while device is connected to xcode, use the simulator and let it play a gpx track.
2) for real world testing, not connected to simu, one possibility is that your app, has a special modus built in, where you set it to "playback" mode. In that mode the app has to create the locations itself, using a timer of 1s, and creating a new CLLocation object.
3) A third possibility is described here:
https://blackpixel.com/writing/2013/05/simulating-locations-with-xcode.html
Working with GPX files with Xcode compatibility
I followed the link given by AlexWien and it was extremely useful: https://blackpixel.com/writing/2013/05/simulating-locations-with-xcode.html
But, I spent quite some time searching for how to generate .gpx files with waypoints (wpt tags), as Xcode only accepts wpt tags.
The following tool converts a Google Maps link (also works with Google Maps Directions) to a .gpx file.
https://mapstogpx.com/mobiledev.php
Simulating a trip duration is supported, custom durations can be specified. Just select Xcode and it gets the route as waypoints.
xCode is picky about the GPX file it accepts.
But, in xCode you can create a GPX file with the format it will accept:
And then just change the content of the file to the location you need.
you can do it on real device by run device in Debug mode
Click Debug->Simulate Location -> add .gpx file for your location during run time
I had a similar issue, but with no source code to run on Xcode.
So if you want to test an application on a real device with a fake location you should use a VPN application.
There are plenty in the App Store to choose from - free ones without the option to choose a specific country/city and free ones which assign you a random location or asks you to choose from a limited set of default options.
it seems with XCode 9.2 the way to import .gpx has changed, I tried the ways described here and did not do. The only way worked for me was to drag and drop the file .gpx to the project navigator window on the left. Then I can choose the country in the simulator item.
Hope this helps to someone.
There are one solution for fake GPS in ios simulator and real device. we can use GPX file for fake GPS and simulation.
I followed the step by step guidelines of GPX file use in Xcode with simulation.
Here is full step by step guidelines of GPX file use. And also you can download the GPX file Demo from github.

Resources