Mach-O Type
[Framework static vs dynamic]
[Mach-O format]
Official page which has some reflection in loader.h. Additionally MH_PRELOAD 0x5, MH_CORE 0x4, MH_DYLINKER 0x7
To setup Mach-O Type determines a linker behaviour
Framework target -> Build Settings -> Mach-O Type
Executable 0x2 (mh_execute/mh_executable) - Is not linked. Is used to create a launchable program - Application, App extension - Widget. Application target is a default setting
Bundle 0x8 (mh_bundle .bundle) - loadable bundle - run time linked. iOS now supports only Testing Bundle target where it is a default setting to generate a Loadable bundle.
System -> Testing Bundle -> tested binary. A location of Testing Bundle will be depended on target, static or dynamic binary...
Dynamic Library 0x6 (mh_dylib .dylib or none) - Load/run time linked.
- With
Framework target - Dynamic Library is a default setting to generate a Dynamic framework
Static Library(staticlib .a) - Compilation time(build time) linked.
- With
Static Library target - Static Library is a default setting to generate a Static library
- With
Framework target - Static Library to generate a Static framework
Relocatable Object File 0x1 (mh_object .o) - Compilation time(build time) linked. It is the simplest form. It is a basement to create executable, static or dynamic format. Relocatable because variables and functions don't have any specific address
It is useful to use otool to determine if binary is dynamic or not -h or -hv
-h Display the Mach header.
-v Display verbosely (symbolically) when possible.
otool -h <path_binary>
//e.g.
otool -h "/Users/alex/Desktop/projects_experiments/ios/LibraryAndFramework/BuildCustom/UtilsSwift/UtilsSwiftFramework.framework/UtilsSwiftFramework"
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
0xfeedfacf 16777228 0 0x00 6 30 3488 0x00100085
filetype is a key point - 6 - 0x6 - Dynamic Library
[Vocabulary]