Enables one or more optional Mob features by patching mix.exs, manifest
files, and generating any required source files.
Usage
mix mob.enable FEATURE [FEATURE ...]Multiple features can be enabled in a single command:
mix mob.enable camera photo_library
mix mob.enable camera photo_library file_sharing liveviewFeatures
liveview
Enables LiveView mode — the Mob app runs a local Phoenix endpoint and displays it in a native WebView. Web developers can ship a mobile app with zero native UI code.
What it does:
- Generates
lib/<app>/mob_screen.ex— aMob.Screenthat opens a WebView athttp://127.0.0.1:PORT/ - Injects the
MobHookLiveView hook intoassets/js/app.js - Injects a hidden
<div id="mob-bridge" phx-hook="MobHook">intoroot.html.heex— this is required for the hook to mount - Updates
mob.exswithliveview_portsoMob.LiveView.local_url/1works
Why the hidden div is required
Phoenix LiveView hooks only execute when a DOM element carrying
phx-hook="MobHook" exists in the rendered page. Registering MobHook in
app.js is necessary but not sufficient — without a matching DOM element the
hook never mounts and window.mob is never replaced with the LiveView-backed
version. Messages would silently route through the native NIF bridge instead
of the LiveView WebSocket, so handle_event/3 would never fire.
See MobDev.Enable module doc and guides/liveview.md for the full
two-bridge architecture explanation.
After running:
- Add
MyApp.MobScreento your supervision tree (or callMob.Screen.start_root(MyApp.MobScreen)from yourMob.App.on_start/0) - Ensure Phoenix is running on the port set in
mob.exs(default: 4000)
camera
Adds camera permission declarations to platform manifests.
- iOS: adds
NSCameraUsageDescriptiontoios/*/Info.plist - Android: adds
<uses-permission android:name="android.permission.CAMERA"/>toandroid/app/src/main/AndroidManifest.xml
photo_library
- iOS: adds
NSPhotoLibraryAddUsageDescriptionto Info.plist - Android: no manifest change needed (API 29+)
file_sharing
- iOS: adds
UIFileSharingEnabledandLSSupportsOpeningDocumentsInPlaceto Info.plist - Android: adds
<provider android:name="FileProvider">with paths config
location
- iOS: adds
NSLocationWhenInUseUsageDescriptionto Info.plist - Android: adds
ACCESS_FINE_LOCATIONpermission
notifications
- iOS: runtime only — no plist key needed
- Android: adds
POST_NOTIFICATIONSpermission (API 33+)