S使用iOS模拟器在expo应用程序上使用gpx文件模拟位置



我想在iOS模拟器中输入一个gpx文件,以模拟沿路线行驶。然而,为了做到这一点,我需要在xcode项目中添加一个gpx文件。我正在使用的项目是使用expo制作的,所以我无法在xcode中打开它。是否有任何变通方法可以在不打开xcode的情况下模拟路线?

可以通过设置模拟器位置等工具在模拟器级别进行模拟定位

只需使用brew install lyft/formulae/set-simulator-location 安装即可

然后设置模拟器位置:set-simulator-location -q Expo 624 University Ave Palo Alto CA(设置为世博会办公室(。

我最终通过使用set simulator location trip simulator解决了我的问题,这是一个使用set simlator location构建的工具。它允许您选择起点和终点,并模拟从起点到终点的旅程。但是,它不允许使用gpx文件。

由于Xcode 14 simctl提供了设置模拟器位置的可能性:

$ 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.

要将它与gpx文件一起使用,您将需要某种包装器来生成这样的命令(注意N坐标是可能的(:

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

根据我的研究,这提供了比我发现的所有其他工具更多的功能,并且优于lyft/formulae/set-simulator-location

如果你喜欢使用UI,LocationSimulator非常好,它也适用于真实的设备!

最新更新