简体   繁体   中英

SImulating location with gpx file on expo app using iOS simulator

I would like to input a gpx file into the iOS simulator to simulate driving along a route. However, in order to do that, I need to add a gpx file to my xcode project. The project I'm using was made using expo, so I cannot open it in xcode. Is there any workaround to be able to simulate the route without opening in xcode?

Simulating location can be done at the simulator level via tools like set-simulator-location

Just install it with brew install lyft/formulae/set-simulator-location

Then set the simulator location: set-simulator-location -q Expo 624 University Ave Palo Alto CA (sets it to the Expo office).

I ended up solving my issue by using set-simulator-location-trip-simulator , a tool built using set-simulator-location . It allows you to select a start and end destination, and simulate a trip from the start to the end. It doesn't allow the use of a gpx file, however.

Since Xcode 14 simctl offers the possibility to set the location of a simulator:

$ xcrun simctl location
Control a device's simulated location
Usage: simctl location <device> <action> [arguments]

    list
        List available simulation scenarios.

    clear
        Stop any running scenario and clear any simulated location.

    set <lat1>,<lon1>
        Set the location to a specific latitude and longitude.

    run <scenario>
        Run a simulated location scenario (use the list action to get a list of scenarios).

    start [--speed=<meters/sec>] [--distance=<meters per second>|--interval=<seconds>] <lat1>,<lon1> <latN>,<lonN>...
        Set the location to a series of waypoints specified as 'lat,lon' pairs, interpolating between them over time.
        At least two waypoints are required. Use '-' to read waypoints from stdin, one waypoint per line.

        Speed specifies how quickly to move between waypoints in meters per second. If not specified 20m/s is used.

        The system will issue location updates along the path between each pair of waypoints. Use distance or interval to 
        control how often those updates are issued. Distance will issue an update every <meters> travelled without regard
        for the time between updates. Interval will issue updates at fixed times without regard for how much
        the location moves between updates.
        If neither are specified an interval of 1.0 seconds is used. If both are specified the system picks ones.

        Example simulating a direct line between San Francisco and New York City, with updates every km:
          set --distance=1000 --speed=260 37.629538,-122.395733 40.628083,-73.768254

Latitude and longitude pairs must be specified using '.' as the decimal separator and ',' as the field separator.

To use it with a gpx file, you will need some kind of a wrapper to generate a command like so (note N coordinates are possible):

xcrun simctl location "iPhone 14 Pro" start 37.629538,-122.395733 40.628083,-73.768254

From my research, this offers much more functionality than all the other tools I have found and is superior to lyft/formulae/set-simulator-location .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM