framework in ios contain static or dynamic library inside

后端 未结 2 635
我寻月下人不归
我寻月下人不归 2021-01-13 04:34

I have come across multiple sites describing that frameworks can contain both static as well as dynamic library. But how do I identify if what the framework actually contain

相关标签:
2条回答
  • 2021-01-13 04:41

    To answer first part of your question, Yes, your understanding is correct that a Framework is just a Directory Structure that bundles the library image (Compiled machine code, headers, resources etc.). To verify if the Framework is actually a Static Library or Dynamic Use the following command

    file Path/To/YourLib.framework/YourLib
    

    If the output of a particular architecture (armv7, arm64 etc) says ar archive its a Static Library, on the other hand if for any architecture it says dynamically linked shared library then its unsurprisingly a dynamic library.

    If you are creating a Framework Project yourself, You can choose to build a Static or Dynamic Image by setting the Mach-O Type Build Setting of your project.

    There are different possibilities in case a same Symbol(For Eg a Function Name) is defined in multiple places. In Almost All of the cases the behaviour would a Link Time Error complaining about multiple Symbols exception being Dynamically Linked Frameworks in which case you might see inconsistent behaviour where a Symbol will be loaded from the Dynamic Framework which was first loaded into the memory.

    0 讨论(0)
  • 2021-01-13 04:43

    It is simple to determine when a file extension is explicit

    • .a - static library
    • .dylib - dynamic library

    you can use file command

    file /some_path/<framework_name>.framework/<framework_name>
    
    //possible results
    current ar archive random library //static library
    dynamically linked shared library //dynamic library
    

    *It is possible to change it in Build Settings a Mach-O type[About] from Static Library target to Dynamic library as a result .a file will be generated, file command show you dynamically linked shared library but it will be static library

    [Vocabulary]
    [Static vs dynamic framework]

    0 讨论(0)
提交回复
热议问题