DalaDev.LocationSpoof (dala_dev v0.4.0)

Copy Markdown View Source

Spoofs the device location from the dev machine.

Useful when testing Dala.Platform.Location without physically moving: pin the device to a specific café, a different hemisphere, or the exact geofence boundary.

Platform support:

  • Android emulator — adb emu geo fix (physical devices need a mock location provider app, which is out of scope)
  • iOS Simulator — xcrun simctl location ... set

Summary

Functions

adb argument list that sets the Android emulator's location.

Clears any spoofed location on device_id (or the first connected device).

xcrun argument list that clears a simulator's spoofed location.

xcrun argument list that sets an iOS simulator's location.

Parses "lat,lng" (or with spaces, or "lat lng") into floats. Returns {:ok, lat, lng} or {:error, reason}. Validates ranges (|lat| <= 90, |lng| <= 180).

Sets the location on one device (device_id nil = first connected).

Types

result()

@type result() :: {:ok, String.t()} | {:error, String.t()}

Functions

android_set_command(serial, lat, lng)

@spec android_set_command(String.t(), float(), float()) :: [String.t()]

adb argument list that sets the Android emulator's location.

clear(device_id, opts \\ [])

@spec clear(
  String.t() | nil,
  keyword()
) :: result()

Clears any spoofed location on device_id (or the first connected device).

ios_clear_command(udid)

@spec ios_clear_command(String.t()) :: [String.t()]

xcrun argument list that clears a simulator's spoofed location.

ios_set_command(udid, lat, lng)

@spec ios_set_command(String.t(), float(), float()) :: [String.t()]

xcrun argument list that sets an iOS simulator's location.

parse_coords(input)

@spec parse_coords(String.t()) :: {:ok, float(), float()} | {:error, String.t()}

Parses "lat,lng" (or with spaces, or "lat lng") into floats. Returns {:ok, lat, lng} or {:error, reason}. Validates ranges (|lat| <= 90, |lng| <= 180).

set(lat, lng, device_id, opts \\ [])

@spec set(float(), float(), String.t() | nil, keyword()) :: result()

Sets the location on one device (device_id nil = first connected).

Test seams: opts[:devices] overrides discovery; opts[:exec] overrides command execution — receives tagged {:adb, args} / {:xcrun, args} and returns {:ok, out} or {:error, out}.