[转]Mac OS X framework 解析
转载地址:http://hi.baidu.com/yonderbyron/item/9838b73472152e009cc65ec8
Mac OS X framework 解析
1、framework是什么?
framework是一个层级的目录结构,将一系列可共享的资源,比如动态共享库、nib文件、图形文件、本地化相关文件、头文件、以及相关引用文档,包装成一个包(package)。可供许多应用程序同时使用。系统在需要的时候载入他们,且只在内存中存在一个副本。
framework的使用方式和一个单独文件一样,通过Core Foundation Bundle Service 或者 Cocoa NSBundle类访问。framework设计目的和动态共享库、静态共享库类似,但有更多的优点:
>framework将相关但是分散的资源整合起来,易于装卸和定位。
>framework可包含比库更丰富多样的资源类型
>不同版本的framework可被包含在同一个framework里,有更好的后向兼容性
>有且仅有一份framework的只读资源存在于memory中。
注:framework可以只包含resources,也programmatic interface不是必须的。当然这中用法很少使用。
Mac OS X 关键的几个framework:包含Carbon、Cocoa、Application Services、Core Services,组合成umbrella framework,将底层的framework和用户程序隔离开来。
2、framework的文件结构
A simple framework bundle
MyFramework.framework/
MyFramework -> Versions/Current/MyFramework
Resources -> Versions/Current/Resources
Versions/
A/
MyFramework
Resources/
English.lproj/
InfoPlist.strings
Info.plist
Current -> A
A framework with multiple versions
MyFramework.framework/
MyFramework -> Versions/Current/MyFramework
Resources -> Versions/Current/Resources
Versions/
A/
MyFramework
Resources/
English.lproj/
InfoPlist.strings
Info.plist
B/
MyFramework
Resources/
English.lproj/
InfoPlist.strings
Info.plist
Current -> B
A framework with additional resource types
MyFramework.framework/
Headers -> Versions/Current/Headers
MyFramework -> Versions/Current/MyFramework
Resources -> Versions/Current/Resources
Versions/
A/
Headers/
MyHeader.h
MyFramework
Resources/
English.lproj/
Documentation
InfoPlist.strings
Info.plist
B/
Headers/
MyHeader.h
MyFramework
Resources/
English.lproj/
Documentation
InfoPlist.strings
Info.plist
Current -> B
Structure of the Core Services umbrella framework
CoreServices.framework/
CoreServices -> Versions/Current/CoreServices
CoreServices_debug -> Versions/Current/CoreServices_debug
CoreServices_profile -> Versions/Current/CoreServices_profile
Frameworks -> Versions/Current/Frameworks
Headers -> Versions/Current/Headers
Resources -> Versions/Current/Resources
Versions/
A/
CoreServices
CoreServices_debug
CoreServices_profile
Frameworks/
CarbonCore.framework
CFNetwork.framework
OSServices.framework
SearchKit.framework
WebServicesCore.framework
Headers/
Components.k.h
CoreServices-gcc3.p
CoreServices-gcc3.pp
CoreServices.h
CoreServices.p
CoreServices.pp
CoreServices.r
Resources/
Info-macos.plist
version.plist
Current -> A
3、framework and binding
binding意指动态绑定Mach-O库(动态库)文件,动态共享库有几个优点:一、memory使用更有效率,二、更容易让开发者修正错误。
关于动态共享库的symbol binding,不同于static linked shared library在编译链接期需要确定symbol是否存在,他是在运行期检查symbol的有效性。这个特点使得动态库存在“lazy linking”的行为:动态链接器自动加载和链接那些需要的模块,也即,一个模块是否链接取决于程序是否有引用这个模块的symbol。
上述特点同样也影响framework code的组织:互相依赖和对应的code应该放在同一个module里,并且必须保证每一个symbol只能在一个library里出现一次。
framework的安装位置也是一个需要考量的因素,注意以下几点:1)第三方的framework安装在/library/Frameworks。 2)一定不要安装在/system/Library/Frameworks。3) 模块搜索顺序:一、链接期指定的显示路径,二、/library/frameworks,三、/system/library/frameworks
4、create a framework
几点注意:编码时使用统一的前缀,以避免和其他framework的symbol冲突。决定是使用private framework还是普通的framework。决定那些code是可以提取做成framework。不要创建umbrella framework
[转]Mac OS X framework 解析的更多相关文章
- 在 Mac OS X 上创建的 .NET 命令行程序访问数据库 (使用Entity Framework 7 )
var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...
- RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more infor
在virtualenv环境下使用matplotlib绘图时遇到了这样的问题: >>> import matplotlib.pyplot as pltTraceback (most r ...
- 出现ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly ....的解决方法
在terminal上运行gluoncv时遇到了一个报错问题. ImportError: Python is not installed as a framework. The Mac OS X bac ...
- Mac OS X 背后的故事
Mac OS X 背后的故事 作者: 王越 来源: <程序员> 发布时间: 2013-01-22 10:55 阅读: 25840 次 推荐: 49 原文链接 [收藏] ...
- 在 Mac OS X 上安装 TensorFlow
在 Mac OS X 上安装 TensorFlow 这个文档说明了如何在 Mac OS X 上安装 TensorFlow. 注意:从 1.2 版本开始,在 Mac OS X 上 TensorFlow ...
- Atitit mac os 版本 新特性 attilax大总结
Atitit mac os 版本 新特性 attilax大总结 1. Macos概述1 2. 早期2 2.1. Macintosh OS (系统 1.0) 1984年2 2.2. Mac OS 7. ...
- Mac OS X 上安装 ASP.NET 5
在Mac OS X Yosemite 10.10.3 中搭建第一个 ASP.NET 5 Web 项目 终于有时间在 Mac 上安装一下 ASP.NET 5,网上有许多教程,但是多数的时间比较早了,版本 ...
- [.net 面向对象程序设计深入](5)MVC 6 —— 构建跨平台.NET开发环境(Windows/Mac OS X/Linux)
[.net 面向对象程序设计深入](5)MVC 6 —— 构建跨平台.NET开发环境(Windows/Mac OS X/Linux) 1.关于跨平台 上篇中介绍了MVC的发展历程,说到ASP.NET ...
- Mac OS平台下应用程序安装包制作工具Packages的使用介绍
一.介绍 Windows下面开发好的应用程序要进行分发时有很多打包工具可供选择,如Inno Setup, InstallShield, NSIS, Advanced Installer, Qt Ins ...
随机推荐
- j2ee Servlet、Filter、Listener
首先,JSP/Servlet规范中定义了Servlet.Filter.Listener这三种角色,并没有定义Interceptor这个角色,Interceptor是某些MVC框架中的角色,比如Stru ...
- poj: 1003
简单题 #include <iostream> #include <stdio.h> #include <string.h> #include <stack& ...
- C++之路进阶——codevs2404(糖果)
2404 糖果 2011年省队选拔赛四川 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 幼儿园里有N个小朋友,l ...
- codeforces 70D Professor's task(动态二维凸包)
题目链接:http://codeforces.com/contest/70/problem/D Once a walrus professor Plato asked his programming ...
- 使用php模拟post的几种方法
<?phpfunction file_get_contents_post($url,$post){$options=array('http'=>array('method'=>'PO ...
- HTML5,添加图片
<img src="0.jpg" width="100" height="150" alt="11">
- Inside TSQL Querying - Chapter 2. Physical Query Processing
Summary Description The SQL language is spoken by most database experts, and all relational database ...
- 分数的加减法——C语言初学者代码中的常见错误与瑕疵(12)
前文链接:分数的加减法——C语言初学者代码中的常见错误与瑕疵(11) 重构 题目的修正 我抛弃了原题中“其中a, b, c, d是一个0-9的整数”这样的前提条件,因为这种限制毫无必要.只假设a, b ...
- 薛非《品悟C-抛弃C程序设计中的谬误与恶习》读后感part1【转】
薛非<品悟C-抛弃C程序设计中的谬误与恶习>读后感part1 作者:宝贝孙秀楠﹣大连程序员 发表于2012年10月5日由admin 出处:http://sunxiunan.com/?p=2 ...
- JNI 回调小记
javah在eclipse中设置参数:location(javah.exe的位置)working dir(${project_loc}/src) -classpath .;./classes -d $ ...