MobDev.AppLifecycleHooks (mob_dev v0.7.21)

Copy Markdown View Source

Detects an Android app that predates the Mob.Device :app lifecycle hooks.

mob 0.9.6 exports mob_send_app_lifecycle/1 and delivers :did_become_active, :did_enter_background etc. on Android, but only if the app's own MainActivity.kt calls nativeNotifyAppLifecycle and its beam_jni.c forwards that to mob_send_app_lifecycle. Both files are app-owned and never re-rendered, so an existing app that upgrades mob gets no events and Mob.Device.foreground?/0 stays true, with no error anywhere. mob_dev detects rather than patches app-owned native source (see decisions/2026-08-25-detect-dont-autopatch-native-source.md).

Summary

Functions

What the app in project_root is missing, given the mob checkout it builds against: :ok, or {:missing, files} with the relative paths that lack their half of the hook. Always :ok for a project without android/ or a mob that doesn't export mob_send_app_lifecycle (adding the hook there would fail to link).

The upgrade steps, with the code to add.

Whether the mob checkout at mob_dir exports mob_send_app_lifecycle (mob 0.9.6+).

The one-line problem statement.

Functions

check(project_root, mob_dir)

@spec check(Path.t(), Path.t() | nil) :: :ok | {:missing, [String.t()]}

What the app in project_root is missing, given the mob checkout it builds against: :ok, or {:missing, files} with the relative paths that lack their half of the hook. Always :ok for a project without android/ or a mob that doesn't export mob_send_app_lifecycle (adding the hook there would fail to link).

fix()

@spec fix() :: String.t()

The upgrade steps, with the code to add.

mob_supports?(mob_dir)

@spec mob_supports?(Path.t() | nil) :: boolean()

Whether the mob checkout at mob_dir exports mob_send_app_lifecycle (mob 0.9.6+).

problem()

@spec problem() :: String.t()

The one-line problem statement.