DalaDev.DeviceClipboard (dala_dev v0.4.0)

Copy Markdown View Source

Reads and writes the device clipboard from the dev machine.

Primary use: pasting long strings (tokens, fixtures, URLs) into a device text field during manual testing instead of typing them on a virtual keyboard. The app-side counterpart is Dala.Platform.Clipboard.

Platform support:

  • iOS Simulator — full read/write via xcrun simctl pbpaste/pbcopy (the sim shares the host clipboard plumbing)
  • Android — not supported by adb on modern Android (clipboard access is blocked for background processes); returns a clear error with the adb shell input text alternative
  • iOS physical — not supported from CLI

Summary

Functions

Reads the clipboard of device_id (or the first connected device).

xcrun argument list that prints an iOS simulator's clipboard.

xcrun argument list that sets an iOS simulator's clipboard to text. Text is passed via stdin (the pbcopy form reads stdin), so this returns the args plus a marker for the dispatcher.

Sets the clipboard of device_id (or the first connected device) to text. Same test seams as get/2.

Types

result()

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

Functions

get(device_id, opts \\ [])

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

Reads the clipboard of device_id (or the first connected device).

Test seams: opts[:devices] overrides discovery, opts[:exec] overrides the xcrun call (receives (args, input), returns {output, code}).

ios_get_command(udid)

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

xcrun argument list that prints an iOS simulator's clipboard.

ios_put_command(udid, text)

@spec ios_put_command(String.t(), String.t()) :: [String.t()]

xcrun argument list that sets an iOS simulator's clipboard to text. Text is passed via stdin (the pbcopy form reads stdin), so this returns the args plus a marker for the dispatcher.

put(text, device_id, opts \\ [])

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

Sets the clipboard of device_id (or the first connected device) to text. Same test seams as get/2.