Mac OS X 中的框架到底是什么?( *.framework 文件夹) [英] What exactly is a Framework in Mac OS X? ( *.framework folders )

查看:74
本文介绍了Mac OS X 中的框架到底是什么?( *.framework 文件夹)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我基本上知道现实生活中的框架是什么.我见过一些包含一些头文件和二进制文件的框架.是这样吗?OS X 框架是否具有特殊功能,而不仅仅是一个包含链接到应用程序的标头和库的文件夹?

解决方案

框架信息

来自 :

<块引用>

与静态链接库和其他类型的动态共享库相比,框架具有以下优势:

  • 框架将相关但独立的资源组合在一起.这种分组使安装、卸载和定位这些资源变得更加容易.
  • 框架可以包含比库更广泛的资源类型.例如,一个框架可以包含任何相关的头文件和文档.一个框架的多个版本可以包含在同一个包中.这使得向后兼容旧程序成为可能.
  • 无论有多少进程在使用这些资源,在任何给定时间,只有一个框架只读资源的副本物理驻留在内存中.这种资源共享减少了系统的内存占用并有助于提高性能.

相关的 SO 问题

您可能想查看 SO 问题 1444543:Mac OS X 上 Python 的框架和非框架构建之间的差异.

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 features other than just being a folder with headers and libraries you link to your application?

解决方案

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.

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.

这篇关于Mac OS X 中的框架到底是什么?( *.framework 文件夹)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆