Compile the program using the following command:
DYLD_INSERT_LIBRARIES=/path/to/inject.dylib ./target_app dylib injection
To understand injection, one must first understand the loader. On macOS, the dynamic linker is dyld . When a process launches, dyld is responsible for loading the executable and its dependent shared libraries into memory. In a standard workflow, an application declares its dependencies in its binary header, and the linker resolves them automatically. Injection, however, forces the loading of a library that the application did not explicitly request. dylib injection
: The injector calls task_for_pid() to get a Mach task port for the target running application. dylib injection