mix mob.adopt.mob_app (mob_dev v0.6.15)

Copy Markdown View Source

Generates the on-device BEAM entry point invoked by Mob's native shell at app launch:

  • lib/<app>/mob_app.ex — the entry module
  • src/<app>.erl — Erlang bootstrap that calls <App>.MobApp.start/0
  • mix.exs patches: erlc_paths: ["src"] + erlc_options: [:debug_info] so the Erlang bootstrap gets compiled

Two flavours of mob_app.ex:

  • LiveView (default) — calls Application.ensure_all_started(:<app>) which boots the host Phoenix endpoint, runs Ecto migrations, sets up the on-device runtime config. secret_key_base is read from config/dev.exs if available (so it matches the host dev server) or freshly generated.
  • Thin client (with --no-live-view) — uses use Mob.App with navigation/1 + on_start/0 callbacks. Does NOT boot Phoenix on-device; the WebView points at a deployed Phoenix server (set config :mob, host_url: ...). The device's BEAM is just the native interop layer.

Options

  • --no-live-view — generate the thin-client mob_app.ex instead of the LiveView-flavoured one. Pairs with the bridge sub-task being skipped under the same flag.

Other orchestrator flags accepted but inert.

Idempotency

  • Files are created with on_exists: :skip. Re-running won't overwrite — delete first if you want to switch between LV and thin flavours.
  • erlc_paths / erlc_options injection checks string presence in mix.exs before patching.

Typically called by mix mob.adopt, not directly.