macho command provides tools for inspecting and modifying Mach-O executable files, including viewing entitlements, managing dynamic library dependencies, and modifying SDK versions.
Usage
Path to the Mach-O binary file to inspect or modify.
Inspection
Entitlements
Display the entitlements embedded in the binary as XML.
Example output
List dynamic libraries
List all dynamic library (dylib) dependencies of the binary.
Example output
Modification
Add dynamic library
Add a new dynamic library dependency to the binary.Common path prefixes:
@rpath/- Relative to runtime search paths@executable_path/- Relative to executable location@loader_path/- Relative to loading binary
Replace dynamic library
Replace an existing dynamic library reference with a new one. Requires exactly two arguments: the old path and the new path.
Set SDK version
Set the minimum SDK version required by the binary.Version format:
MAJOR.MINOR.PATCH (e.g., 16.0.0, 17.2.0)Examples
View binary entitlements
List all dependencies
Inject a tweak library
Update library path
Lower SDK version requirement
Use cases
Tweak injection
Add custom dylib tweaks to an app binary:Framework path updates
Update framework paths when relocating frameworks:Compatibility patching
Lower the minimum iOS version requirement:Debugging entitlements
Verify entitlements after signing:Technical details
Mach-O format
Mach-O (Mach Object) is the executable file format used by macOS and iOS. It contains:- Header: Architecture and file type information
- Load commands: Instructions for the dynamic linker
- Segments: Code, data, and other binary content
- Code signature: Cryptographic signature and entitlements
Fat binaries
Many iOS binaries are “fat” or “universal” binaries containing multiple architectures (arm64, arm64e). Themacho command currently operates on the first architecture in the binary.
Future versions may support selecting specific architectures via an
--arch flag.Dylib paths
iOS and macOS support several special path prefixes for dynamic library loading:@rpath/- Searches runtime search paths (LC_RPATH load commands)@executable_path/- Relative to the main executable@loader_path/- Relative to the binary that loads this dylib