Search code examples
iosxcodeflutterios-simulator

iOS Simulator custom City Run outside Xcode


I'm currently developing a Flutter app using VSCode and the Xcode iOS-Simulator.

While developing, I would like to simulate a "City Run" using custom locations instead of the pre-loaded iOS City Run-locations.

I was able to add a custom city Run to a Xcode-Project (using a .gpx-file), but could only use it while Debugging the Xcode-Project.

Now, I couldn't figure out a way to change or update the City-Run locations in a project not running in Xcode, but VSCode.

Do any of you have an idea on how to either:

  • Add locations to the iOS Simulator without using an Xcode-project
  • Add locations to the simulator using Xcode to permanently use those inside the simulator (not only while debugging inside Xcode)
  • update the default locations of the City Run used by the iOS Simulator

I'm currently running:

  • Mac OS 11.1 (Big Sur)
  • MacBook Pro (13-inch, M1, 2020)
  • Flutter 1.22.6
  • Simulator: iPhone 12 Pro Max - iOS 14.3

Thank you very much guys! Any help will be highly appreciated!🙏

Cheers, Tobi


Solution

  • For now I found workaround which might not be beautiful, but it does the job for me.

    I followed along this article and wrote a little AppleScript to regularly update the current location and simulate a "City Run".

    Although it has a couple of downsides (e.g. Simulator must be the frontmost process) it does the job for simulating the City Run during development for me.

    Still, if anyone comes up with a better solution, please let me know.

    This is what the script does look like for now:

    on run
        tell application "System Events"
            tell process "Simulator"
                set frontmost to true
                click menu item "Custom Location…" of menu of menu item "Location" of menu "Features" of menu bar 1
                set popup to window "Custom Location"
                set value of text field 1 of popup to "<lat here>"
                set value of text field 2 of popup to "<long here>"
                click button "OK" of popup
                delay 2
                -- (Further locations here)
            end tell
        end tell
    end run
    

    Cheers,

    Tobi