MobDev.Enable.Igniter (mob_dev v0.5.5)

Copy Markdown View Source

Igniter-aware feature handlers for mix mob.enable.

One function per <feature> returning igniter -> igniter. Phase 4 of the build-system migration moves each handler off the legacy string-mutation path (where each helper writes files immediately) and onto Igniter's update_file / create_new_file flow (where every change rolls into a single dry-run-able diff before any file is written).

Per-feature state:

FeatureIgniter-routed (iter 1)Elixir AST-aware
camerayes(no Elixir surface)
photo_libraryyes(no Elixir surface)
locationyes(no Elixir surface)
file_sharingyes(no Elixir surface)
notificationsyes(no Elixir surface)
liveviewyesmob_screen.ex via create_module (iter 1)
pythonyesdep via add_dep (iter 2); paths module via create_module (iter 1)

iter 1 wrapped every feature in Igniter so the diff preview + atomic apply flow applies uniformly. iter 2 swapped python's mix.exs dep-injection from MobDev.Enable.inject_pythonx_dep (regex) to Igniter.Project.Deps.add_dep (AST). The remaining text-level patches (assets/js/app.js, root.html.heex) are non-Elixir source and stay text-level — AST tooling for those isn't a win.

All handlers are called with the project root as cwd (Igniter expects paths relative to cwd). The app_name arg is the project's :app Mix config (a string like "my_app") for any feature that needs to template it into generated source.

Summary

Functions

Adds an Android <uses-permission> line to AndroidManifest.xml.

Adds an iOS Info.plist <key>...<string>... pair if not already present.

Enables MLX + EMLX (Apple's MLX numerics + the EMLX Nx backend) for iOS. Adds :nx and :emlx to deps; generates a tiny <App>.MLInit helper that picks EMLX.Backend at boot with a clean fallback to Nx.BinaryBackend if the NIF can't load.

Enables the NxEigen Nx backend (Eigen-backed C++ NIF) on both iOS and Android. mob_dev cross-compiles libnx_eigen.a per arch from the :nx_eigen Hex dep + the Eigen header tarball it auto-downloads.

Functions

add_android_permission(igniter, permission)

@spec add_android_permission(Igniter.t(), String.t()) :: Igniter.t()

Adds an Android <uses-permission> line to AndroidManifest.xml.

No-op (with a notice) when no AndroidManifest.xml is found. Idempotent on the permission name — re-running with the same permission skips the patch silently.

add_ios_plist_key(igniter, key, value, opts \\ [])

@spec add_ios_plist_key(Igniter.t(), String.t(), String.t(), keyword()) :: Igniter.t()

Adds an iOS Info.plist <key>...<string>... pair if not already present.

No-op (with a notice) when no Info.plist is found under ios/. The insertion is idempotent — runs that find the key already present skip the patch silently.

enable_camera(igniter, app_name)

@spec enable_camera(Igniter.t(), String.t()) :: Igniter.t()

enable_file_sharing(igniter, app_name)

@spec enable_file_sharing(Igniter.t(), String.t()) :: Igniter.t()

enable_liveview(igniter, app_name)

@spec enable_liveview(Igniter.t(), String.t()) :: Igniter.t()

enable_location(igniter, app_name)

@spec enable_location(Igniter.t(), String.t()) :: Igniter.t()

enable_mlx(igniter, app_name)

@spec enable_mlx(Igniter.t(), String.t()) :: Igniter.t()

Enables MLX + EMLX (Apple's MLX numerics + the EMLX Nx backend) for iOS. Adds :nx and :emlx to deps; generates a tiny <App>.MLInit helper that picks EMLX.Backend at boot with a clean fallback to Nx.BinaryBackend if the NIF can't load.

The :emlx_nif static NIF entry is already in MobDev.StaticNifs defaults — MobDev.NativeBuild auto-detects the :emlx dep, downloads the cross-compiled MLX bundle, and sets MOB_STATIC_EMLX_NIF so the driver_tab + linker include EMLX. So mob.enable mlx is mostly about the dep wiring and the helper module.

enable_notifications(igniter, app_name)

@spec enable_notifications(Igniter.t(), String.t()) :: Igniter.t()

enable_nxeigen(igniter, app_name)

@spec enable_nxeigen(Igniter.t(), String.t()) :: Igniter.t()

Enables the NxEigen Nx backend (Eigen-backed C++ NIF) on both iOS and Android. mob_dev cross-compiles libnx_eigen.a per arch from the :nx_eigen Hex dep + the Eigen header tarball it auto-downloads.

The :nx_eigen static-NIF entry is already in MobDev.StaticNifs defaults — MobDev.NativeBuild auto-detects the :nx_eigen dep and sets MOB_STATIC_NX_EIGEN_NIF so the driver_tab

  • linker include it. mob.enable nxeigen does the dep wiring + the helper module.

enable_photo_library(igniter, app_name)

@spec enable_photo_library(Igniter.t(), String.t()) :: Igniter.t()

enable_python(igniter, app_name)

@spec enable_python(Igniter.t(), String.t()) :: Igniter.t()