How to set fake GPS location on IOS real device

151,975

Solution 1

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

Solution 2

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.

Specify debug location

You can generate GPX files here manually: http://www.bikehike.co.uk/mapview.php (from answer: https://stackoverflow.com/a/17478860/881197)

Solution 3

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.

Solution 4

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.

Solution 5

xCode is picky about the GPX file it accepts.

But, in xCode you can create a GPX file with the format it will accept:

enter image description here

enter image description here

enter image description here

And then just change the content of the file to the location you need.

Share:
151,975

Related videos on Youtube

Maksim Alekseychik
Author by

Maksim Alekseychik

Updated on July 09, 2022

Comments

  • Maksim Alekseychik
    Maksim Alekseychik about 2 years

    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?

  • Maksim Alekseychik
    Maksim Alekseychik over 10 years
    Could you please share link for manual to use the simulator and let it play a gpx track? For 'black box' testing
  • AlexWien
    AlexWien over 10 years
    Something simmilar to: Xcode->Simulator->Location->GpxFile: choose gpx file. You should be able to find out that yourself.
  • Maksim Alekseychik
    Maksim Alekseychik over 10 years
    Thank you, I found it. Unfortunately, I can't understand how can I make my real iPhone (or installed app) to get fake lokation, not simulator
  • AlexWien
    AlexWien over 10 years
    If you read my answer then there is written that you or the sw developpers of that application have to change the programm code, such that it has a playback mode. In that playback mode, a time fires once a second and reads the gps data from a csv file, or xml or gpx file, csv is by far the easiest. Then when the time fired create a CLLocation object with the data from the current line in the file. I recomend to read the whole file into an array and each second access the next psoition in the array.
  • Matt Foley
    Matt Foley about 10 years
    This is the correct answer, it will spoof the location for all apps on the device, even your Maps app, Foursquare, Facebook etc. neglectedpotential.com/2013/04/…
  • noir
    noir about 10 years
    This is not correct. You can use a GPX file to fake locations on a device when building from Xcode to your device.
  • AlexWien
    AlexWien about 10 years
    @noir, This works partially. You don't get all location attributes. altitude seems to be always 0. And read the third comment: He asked for a fake without Xcode simulator!!
  • noir
    noir about 10 years
    Xcode and the Simulator are two different things. My comment was about how to do it building from Xcode to a device, not the Simulator.
  • AlexWien
    AlexWien about 8 years
    @noir: you are right, there is a third way, I updated my answer, and removed "the only possibility" in topic 2
  • Aranda
    Aranda over 7 years
    This answer should have more upvotes. It is the most convenient way to mock a moving location in Xcode.
  • N Jacobs
    N Jacobs about 7 years
    Also other apps running will take over this GPS position.