Search code examples
iosxcodeautomator

Automating Xcode' Debug > Simulate Location command


Is there any programmatic way to control the xcode > simulate location command? I have external location test scripts I'd like to run, and ideally the test suite could cause xcode to change the location of the connected phone at will.

Is this possible, and if so how?


Solution

  • There is a GitHub project called Pokemon-Go-Controller that does exactly what you want.

    Overview of the solution:

    1. Create a gpx file
    2. Create a blank project referencing (not copying) that gpx file and run it on your device
    3. Run auto clicker which will constantly click update location in Xcode
    4. Update gpx file using some script and the device location will be automatically updated

    Instead of the auto clicker you can use this Apple Script:

    #Will continue update the location to the location name below from Xcode:
    
    property locationName : "pokemonLocation" #name of your gpx filex
    
    ###########################
    tell application "System Events"
        tell process "Xcode"
            repeat while true
                click menu item locationName of menu 1 of menu item "Simulate Location" of menu 1 of menu bar item "Debug" of menu bar 1
                delay 0.2
            end repeat
        end tell
    end tell