1

I am trying to fake the location of my simulator programatically. I have seen other posts where they have asked to use .gpx files. But, I am doing the automation testing wherein I need to send my own lat/long values. Ultimately, my simulator needs to pick up the lat/long values that I have provided through the code.

  • 3
    Does this not work for you? https://stackoverflow.com/questions/7907734/string-to-cllocation-latitude-and-longitude – Casey West Oct 27 '17 at 21:32
  • Using .gpx files is the only way. This option is in scheme edit. – Ryan Oct 27 '17 at 21:33
  • 1
    Move all of your location getting code out into its own service (class) that implements a generic protocol. Then inject an instance of the protocol into any part of your app that needs it. In test, inject a mock one -- this is called "dependency injection", if you want to research it. – Lou Franco Oct 28 '17 at 00:32
  • @Ryan - you are right we got to use the .gpx file anyways – kanduri vivek Nov 03 '17 at 16:06

1 Answers1

0

I just found a way to answer my question. I had to write an AppleScript to achieve the automation of the location. Something like this -->

tell application "System Events" tell process "Xcode"

tell menu bar 1 tell menu bar item "Debug" tell menu "Debug" tell menu item "Simulate Location" click tell menu "Simulate Location" click menu item "Home" delay 1 end tell end tell end tell end tell end tell end tell