What exactly is a Framework in Mac OS X? ( *.framework folders )

前端 未结 3 1893
你的背包
你的背包 2020-12-14 09:04

Ok, I know basically what a framework is in real life. I\'ve seen some frameworks that hold some header files and a binary. Is that it? Does an OS X framework have special f

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 09:18

    Framework Information

    From the Apple Developer Connection: Framework Definition:

    A framework is a bundle (a structured directory) that contains a dynamic shared library along with associated resources, such as nib files, image files, and header files. When you develop an application, your project links to one or more frameworks. For example, iPhone application projects link by default to the Foundation, UIKit, and Core Graphics frameworks. Your code accesses the capabilities of a framework through the application programming interface (API), which is published by the framework through its header files. Because the library is dynamically shared, multiple applications can access the framework code and resources simultaneously. The system loads the code and resources of a framework into memory, as needed, and shares the one copy of a resource among all applications.

    alt text

    From the Framework Programming Guide: What are Frameworks?:

    Frameworks offer the following advantages over static-linked libraries and other types of dynamic shared libraries:

    • Frameworks group related, but separate, resources together. This grouping makes it easier to install, uninstall, and locate those resources.
    • Frameworks can include a wider variety of resource types than libraries. For example, a framework can include any relevant header files and documentation. Multiple versions of a framework can be included in the same bundle. This makes it possible to be backward compatible with older programs.
    • Only one copy of a framework’s read-only resources reside physically in-memory at any given time, regardless of how many processes are using those resources. This sharing of resources reduces the memory footprint of the system and helps improve performance.

    Related SO Question

    You might want to look at SO question 1444543: Differences between Framework and non-Framework builds of Python on Mac OS X.

提交回复
热议问题