28

I want to simulate fake location on my iPhone 5S device using specific longitude and latitude. Is there a way to do this in XCode. I tried using the simulate location feature by adding a GPX file in XCode but it's not working. Thank you in advance.

AWSSET
  • 397
  • 1
  • 4
  • 12
  • 1
    why you don't set your "fake" location to a programatically created location? `CLLocationCoordinate2D CLLocationCoordinate2DMake( CLLocationDegrees latitude, CLLocationDegrees longitude)` – donmarkusi Sep 16 '14 at 13:32
  • 1
    `Debug` > `Simulate Location` menu in Xcode **SHOULD** work. we need more info. – rintaro Sep 16 '14 at 13:34
  • @rintaro: the title contains the words "real iOS device" and your answer applies to simulators – donmarkusi Sep 16 '14 at 13:57
  • 2
    @donmarkusi It's not about Simulator menu, but Xcode menu. it works on "real iOS device". see:https://developer.apple.com/library/ios/recipes/xcode_help-debugger/articles/simulating_locations.html – rintaro Sep 16 '14 at 14:03
  • @AWSSET https://developer.apple.com/library/ios/recipes/xcode_help-scheme_editor/Articles/simulating_location_on_run.html#//apple_ref/doc/uid/TP40010402-CH10l Is this what you looking for? – rintaro Sep 16 '14 at 14:08
  • oh i am sorry, i didn't know that :) – donmarkusi Sep 16 '14 at 14:12
  • @rintaro I tried loading a gpx file in the Simulator menu, but nothing happens.... I also tried adding the gpx file to scheme, but still nothing happens.... Do I need to configure something else? – AWSSET Sep 16 '14 at 14:46
  • Does locations from the menu(e.g. Tokyo,Japan) work? If yes, I think your GPX is corrupted. otherwise, I cannot answer without your code how/when get the location. – rintaro Sep 16 '14 at 15:56
  • @rintaro Hi! I tried restarting my project and it worked amazingly! thank you very much for your help! :) – AWSSET Sep 17 '14 at 03:21

2 Answers2

40

It is possible.

You only have to: 1) plug your device to the computer. 2) run an app in the real device (it is the same which application). It is only to have the menu enabled. 3) in Xcode (not in the simulator) Go to menu: Debug -> Simulate Location and select one or add a GPX file.

It will simulate the location not only for the application executed but for all of them.

I suppose that the phone must be in developer mode but if you run apps from Xcode it must be anyway.

I've tested it from Xcode 6 in an iPhone 4 iOS 7.1.2

Hope it helps

buttcmd
  • 641
  • 5
  • 14
5

In addition to the method for setting a simulated location at runtime as mentioned in this answer, you can set/change the default simulated location for a default device/configuration prior to runtime in Xcode at:

Product (menu) > Scheme > Edit Scheme > Options (tab) > Default Location

Xcode Edit Scheme window with Options tab and Default Location selection shown

Jon Schneider
  • 25,758
  • 23
  • 142
  • 170