41

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?

Rajesh
  • 820
  • 8
  • 18
Maksim Alekseychik
  • 3,498
  • 5
  • 15
  • 15

9 Answers9

48

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)

Community
  • 1
  • 1
SolidSun
  • 2,059
  • 1
  • 22
  • 27
14

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.

Idan Moshe
  • 1,955
  • 4
  • 26
  • 64
  • 2
    This is the correct answer, it will spoof the location for all apps on the device, even your Maps app, Foursquare, Facebook etc. http://www.neglectedpotential.com/2013/04/spoofing-location-services-in-ios/ – Matt Foley Apr 19 '14 at 00:48
10

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

AlexWien
  • 27,247
  • 5
  • 48
  • 78
  • Could you please share link for manual to use the simulator and let it play a gpx track? For 'black box' testing – Maksim Alekseychik Mar 03 '14 at 18:28
  • Something simmilar to: Xcode->Simulator->Location->GpxFile: choose gpx file. You should be able to find out that yourself. – AlexWien Mar 03 '14 at 19:00
  • 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 – Maksim Alekseychik Mar 03 '14 at 19:10
  • 1
    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. – AlexWien Mar 03 '14 at 19:27
  • 5
    This is not correct. You can use a GPX file to fake locations on a device when building from Xcode to your device. – noir May 04 '14 at 00:15
  • @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!! – AlexWien May 06 '14 at 18:43
  • 1
    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. – noir May 20 '14 at 21:52
  • @noir: you are right, there is a third way, I updated my answer, and removed "the only possibility" in topic 2 – AlexWien Apr 14 '16 at 20:26
5

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.

K.K
  • 2,337
  • 1
  • 24
  • 32
  • 1
    This answer should have more upvotes. It is the most convenient way to mock a moving location in Xcode. – Aranda Feb 14 '17 at 04:17
2

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.

Jens
  • 5,615
  • 1
  • 45
  • 71
1

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

ABHI
  • 7
  • 4
1

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.

Goran Stoyanov
  • 1,966
  • 1
  • 18
  • 24
0

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.

Jose Rojas
  • 3,310
  • 3
  • 21
  • 35
0

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.

Bera Bhavin
  • 405
  • 3
  • 9