MobDev.MobDirCheck (mob_dev v0.7.8)

Copy Markdown View Source

Detects a mob.exs mob_dir that names a different mob than the :mob dependency.

The native build compiles mob's C/ObjC/Swift sources (-Dmob_dir=…) from mob_dir, while Mix compiles mob's Elixir side from the resolved :mob dependency (Mix.Project.deps_paths()[:mob]). When those are two checkouts, the app ships native code from one commit and BEAMs from another, and nothing fails: a fix in one half silently doesn't reach the device (MOB-351). Native builds stop on a mismatch; see decisions/2026-10-01-mob-dir-must-match-mob-dep.md.

Summary

Functions

Whether mob_dir and dep_path are the same directory: :ok, or {:mismatch, mob_dir, dep_path} with both paths expanded.

Raises Mix.Error naming both paths when the configured mob_dir isn't the current project's :mob dependency. Call before compiling native code.

The resolved :mob dependency path of the current Mix project, or nil.

How to make the two agree.

The full error for a mismatch, naming both paths and the fixes.

Functions

check(mob_dir, dep_path)

@spec check(Path.t() | nil, Path.t() | nil) :: :ok | {:mismatch, Path.t(), Path.t()}

Whether mob_dir and dep_path are the same directory: :ok, or {:mismatch, mob_dir, dep_path} with both paths expanded.

:ok when either is nil: an unset mob_dir or a project without a :mob dependency has nothing to compare. Two existing directories are compared by identity (device + inode), so a symlinked or differently-cased path to the same checkout matches; otherwise by resolved real path.

check!(mob_dir)

@spec check!(Path.t() | nil) :: :ok

Raises Mix.Error naming both paths when the configured mob_dir isn't the current project's :mob dependency. Call before compiling native code.

dep_path()

@spec dep_path() :: Path.t() | nil

The resolved :mob dependency path of the current Mix project, or nil.

fix(mob_dir, dep_path)

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

How to make the two agree.

message(mob_dir, dep_path)

@spec message(Path.t(), Path.t()) :: String.t()

The full error for a mismatch, naming both paths and the fixes.