Watches lib/ for source changes and automatically compiles + hot-pushes
updated modules to all running Android and iOS devices.
Apps must already be running. Modules are loaded in place — no restart. Only modules that actually changed are pushed each cycle.
Press Ctrl-C to stop.
Options: --cookie Erlang cookie (default: mob_secret) --debounce ms to wait after a change before compiling (default: 300) --interval ms between file-change polls (default: 500)
Examples:
mix mob.watch
mix mob.watch --debounce 500
mix mob.watch --cookie my_cookieUnder the hood
mix mob.watch is an mtime-polling file watcher that drives mix compile and
nl/1 in a loop:
# On startup:
writes OS PID → _build/mob_watch.pid # used by mix mob.watch_stop
# Each cycle (every --interval ms):
snapshot mtimes of lib/**/*.ex
if any changed:
:timer.sleep(debounce_ms) # wait for format-on-save to settle
System.cmd("mix", ["compile"]) # compile in a subprocess
for each changed BEAM, on each node:
:rpc.call(node, :code, :load_binary, [...])Compile runs in a subprocess (not Mix.Task.run("compile")) so that Mix's
task cache doesn't prevent recompilation on subsequent file saves.
The watch loop is equivalent to running mix compile && nl(ChangedModule) in
a terminal after every save — mix mob.watch just does it automatically.
Summary
Functions
@spec pid_file() :: String.t()