mix mob.new (mob_new v0.1.40)

Copy Markdown View Source

Creates a new Mob project with Android and iOS boilerplate.

mix mob.new APP_NAME [--liveview] [--ios | --android] [--no-install] [--dest DIR] [--local]

Platform selection

By default the generator emits boilerplate for both Android and iOS. Pass one of the platform flags to scope it to a single platform:

mix mob.new my_app --ios        # iOS only — no android/ directory generated
mix mob.new my_app --android    # Android only — no ios/ directory generated
mix mob.new my_app              # both (default)

--no-ios and --no-android are equivalent inverse forms (kept for back-compat). mix mob.install, mix mob.deploy, and mix mob.doctor detect the project's platform set from on-disk layout, so a single-platform project skips the absent platform's setup automatically.

Options

  • --liveview — generate a Phoenix LiveView app wrapped in a Mob WebView.
                   Calls `mix phx.new` to scaffold a Phoenix project, then
                   adds the Mob native boilerplate and LiveView bridge patches
                   (MobHook in app.js, mob-bridge element in root.html.heex,
                   MobScreen, mob.exs with liveview_port). Requires
                   `phx_new` archive to be installed (`mix archive.install hex phx_new`).
  • --ios — generate iOS boilerplate only (skip android/)
  • --android — generate Android boilerplate only (skip ios/)
  • --no-ios — alias for --android (skip iOS boilerplate)
  • --no-android — alias for --ios (skip Android boilerplate)
  • --no-install — skip running mix deps.get after generation
  • --dest DIR — create project in DIR (default: current directory)
  • --local — use path: deps pointing to local mob/mob_dev repos
                   instead of hex version constraints. **For Mob framework
                   contributors only**  not intended for app developers.
                   Paths resolved from `MOB_DIR` / `MOB_DEV_DIR` env vars,
                   falling back to `./mob` / `./mob_dev`, then `../mob` /
                   `../mob_dev`. Also pre-fills `mob.exs` with real paths
                   so `mix mob.install` skips path configuration prompts.

What gets generated (native mode, default)

APP_NAME/
  mix.exs
  lib/APP_NAME/app.ex
  lib/APP_NAME/home_screen.ex
  android/
    settings.gradle
    build.gradle
    app/
      build.gradle
      src/main/
        AndroidManifest.xml
        java/com/mob/APP_NAME/MainActivity.kt
        java/com/mob/APP_NAME/MobBridge.kt
        java/com/mob/APP_NAME/MobNode.kt
        java/com/mob/APP_NAME/MobScannerActivity.kt
    gradle.properties
  ios/
    beam_main.m
    Info.plist

What gets generated (--liveview mode)

Everything mix phx.new APP_NAME --no-install generates, plus:

APP_NAME/
  lib/APP_NAME/mob_screen.ex      # Mob.Screen wrapping the Phoenix WebView
  mob.exs                          # Mob config with liveview_port: 4000
  android/                         # same Android boilerplate as native mode
  ios/                             # same iOS boilerplate as native mode

Patches applied to the Phoenix project:

  • assets/js/app.js — MobHook definition + registration
  • lib/APP_NAME_web/.../root.html.heex — mob-bridge hidden div
  • lib/APP_NAME/application.ex — Mob.App child in supervision tree
  • mix.exs — mob / mob_dev deps added

After generation, run:

cd APP_NAME
mix mob.install    # icon generation + any first-run setup