Reputation: 1302
What is Mach-O type in Build Setting in Xcode? and what should it be Set on?
it has these options "Executable" "Dynamic Library" "Bundle" "Static Library" "Relocatable Object File"
I had an error "Apple Mach-O Linker Error Group" since I changed it from Executable to Static Library my error went off, I wanna know is that ok that I changed it? and what all those options mean so I won't face another error in the future.
Upvotes: 2
Views: 3660
Reputation: 34225
Mach-O Type(MACH_O_TYPE)
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 settingBundle
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.
Framework target
- Dynamic Library
is a default setting to generate a Dynamic framework
Static Library
(staticlib
.a) - Compilation time(build time) linked.
Static Library target
- Static Library
is a default setting to generate a Static library
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 addressIt 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
Upvotes: 2
Reputation: 721
For more detail Building Mach-O Files and Xcode Build Setting Reference
Upvotes: 3