# `MobDev.Emulators`
[🔗](https://github.com/genericjam/mob_dev/blob/master/lib/mob_dev/emulators.ex#L1)

List, start, and stop Android emulators (AVDs) and iOS simulators.

Backs `mix mob.emulators`. Pure-ish — each function shells out to `emulator`,
`adb`, or `xcrun simctl` exactly once and returns a parsed result. UI-shape
decisions (formatting, colors, exit codes) live in the Mix task.

## Naming

Android calls them "emulators", iOS calls them "simulators". This module
uses "emulator" for the cross-platform concept (configured-but-runnable
virtual device) and reserves "simulator" for iOS-specific descriptions in
the help text. The struct's `:platform` field disambiguates.

# `t`

```elixir
@type t() :: %MobDev.Emulators{
  id: String.t(),
  name: String.t(),
  platform: :android | :ios,
  running: boolean(),
  runtime: String.t() | nil,
  serial: String.t() | nil
}
```

# `list_android`

```elixir
@spec list_android() :: {:ok, [t()]} | {:error, String.t()}
```

Returns all configured Android AVDs, including whether each is currently
running. Returns `{:error, reason}` when the Android SDK isn't reachable.

# `list_ios`

```elixir
@spec list_ios() :: {:ok, [t()]} | {:error, String.t()}
```

Returns all installed iOS simulators (across runtimes) marked with their
current state. Returns `{:error, reason}` on a non-macOS host or when
xcrun isn't available.

# `start_android`

```elixir
@spec start_android(String.t()) :: :ok | {:error, String.t()}
```

Starts an Android AVD by name. Returns `:ok` once the emulator process is
spawned (it boots in the background; `adb wait-for-device` is the caller's
responsibility if they need to know when it's ready).

# `start_ios`

```elixir
@spec start_ios(String.t()) :: :ok | {:error, String.t()}
```

Boots an iOS simulator by UDID and brings the Simulator.app to focus.
No-op-with-success if the sim is already booted.

# `stop_android`

```elixir
@spec stop_android(String.t()) :: :ok | {:error, String.t()}
```

Shuts down a running Android emulator by adb serial (e.g. "emulator-5554").

# `stop_ios`

```elixir
@spec stop_ios(String.t()) :: :ok | {:error, String.t()}
```

Shuts down a booted iOS simulator by UDID. Pass the literal string `"all"`
to shut down every booted simulator at once (`xcrun simctl shutdown all`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
