Documentation
Hot reload
Reload compiled Walnut into a running Simulator or device app without killing the process.
Edit .walnut → recompile → push into the app → swap the live program → re-render.
walnut simulator --watch and walnut device --watch enable hot reload. Use --relaunch when you want a full rebuild and restart on every change.
Host scripts (walnut run / walnut repl) are separate — see jit.md.
Quick start (Simulator)
cd MyApp
walnut simulator --watch
# Full rebuild + relaunch on each change instead:
walnut simulator --relaunch
--watch also turns on the debug server used for reload (debug.md).
What you should see
- First run: full typecheck → compile → Xcode build → launch.
- Edit a label (or other body) in your Walnut sources.
- Within a short while:
→ Change detected — hot reloading…
✓ parse …
✓ typecheck …
✓ emit …
✓ clang …
✓ reload preserve model · …ms
✓ hot reload · 180ms total
Edits that do not change the program’s exported types preserve the live model. Model / Msg / type export changes reinit safely.
Quick start (device)
walnut device login
walnut device --watch --device f --host <phone-lan-ip>
- Cold install builds and launches with the debug server listening.
- Later edits recompile, copy the new binary into the app’s Documents folder, and send a reload command over the network.
--host should be the phone’s LAN IP (printed at launch). You can set WALNUT_DEBUG_HOST instead of passing --host every time.
walnut device --relaunch --device f
Manual reload (from the debug console)
debug> reload
debug> reload /path/to/Main.dylib reinit
debug> reload /path/to/Main.dylib preserve
On device, omit the path after the CLI has already pushed the file into Documents.
Flags
| Flag | Meaning |
|---|---|
--watch | Hot reload on .walnut change |
--hot | Emit a reloadable binary (implied by --watch) |
--relaunch | With watch: full rebuild + terminate + relaunch each change |
--no-hot | Same as --relaunch when watching |
--host | Device only: debug server IP/hostname |
Safety
- Type / export change:
reinit— drop the model, runinitagain. - Body-only change:
preserve— keep the model, swapupdate/view/subscriptions.
Related
- device.md — physical install and signing
- debug.md — attach / console while iterating
- jit.md — host scripts and REPL (not hot reload)
- toolchain.md — CLI overview