Skip to main content

Location · SetLocation · ClearLocation · FollowRoute · FollowGPX

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Read where the device believes it is, or place it somewhere. These call app_location.

Location​

func (d *Device) Location(ctx context.Context) (Location, error)

Location reports where the device is. Android only: simctl location has no get, so on iOS this returns an error saying so rather than a position it never read.

SetLocation​

func (d *Device) SetLocation(ctx context.Context, lat, lon float64) error

SetLocation places the device at a coordinate.

On Android this goes through a test provider, is read back, and works on real hardware. On iOS it goes through simctl and cannot be confirmed — the call succeeding means the request was accepted, not that an app will read it.

ClearLocation​

func (d *Device) ClearLocation(ctx context.Context) error

ClearLocation removes the injected position.

It does not clear the device's last known location, which Android caches, so a Location straight afterwards still reports the injected fix with Mocking false.

FollowRoute​

func (d *Device) FollowRoute(ctx context.Context, points [][2]float64, speedMPS float64) error

FollowRoute moves the device along waypoints at speedMPS meters per second. Two or more points; pass 0 for the default speed.

On iOS the simulator interpolates the route itself. On Android the daemon steps a test provider once a second, since the platform has no route command — either way this returns as soon as the route starts.

FollowGPX​

func (d *Device) FollowGPX(ctx context.Context, path string, speedMPS float64) error

FollowGPX follows a GPX file, reading it on the machine running the daemon.

Examples​

Put the device in London​

if err := dev.SetLocation(ctx, 51.5074, -0.1278); err != nil {
return err
}

The same call from the command line, mobium location 51.5074 -0.1278, printed on an Android 15 emulator:

the device is at 51.507400,-0.127800, injected and read back

mobium location 51.5074 -0.1278 on an Android 15 emulator

mobium location 51.5074 -0.1278 on an Android 15 emulator

Give it back its own position​

if err := dev.ClearLocation(ctx); err != nil {
return err
}

The same call from the command line, mobium location --clear, printed on an Android 15 emulator:

the test provider is removed — the device will report its own position the next time something asks for one. Its last known location is still the injected one until then; Android keeps that cache and nothing here can clear it