What is Mach-O type should I use it in my iOS Objective-C project?

狂风中的少年 提交于 2020-04-28 09:59:23

问题


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.


回答1:


For more detail Building Mach-O Files and Xcode Build Setting Reference




回答2:


To setup Mach-O Type [Mach-O format] determines a linker behaviour

Framework target -> Build Settings -> Mach-O Type
  • Executable - Is not linked. Is used to create a launcheble program - Application. Application target is a default setting
  • 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 - Load/run time linked.
    • Framework target - Dynamic Library is a default setting to generate a Dynamic framework
  • Static Library - 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 - Compilation time(build time) linked. It is a kind of Static Library extension. All .o files will be relinked at build time and a new single object file will be generated. For example it can be used for Symbols hidden by default. It is simple to check using otool[About] command
//Relocatable Object File
otool -L "libRelocatable.a"
Archive : /libRelocatable.a
/libRelocatable.a(relocatable_object_file.o):
/libRelocatable.a(MyClass.o):

//Static library
otool -L "/libStatic.a"
/libStatic.a:

[Vocabulary]
[Framework static vs dynamic]



来源:https://stackoverflow.com/questions/45300314/what-is-mach-o-type-should-i-use-it-in-my-ios-objective-c-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!