[转]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 ...
随机推荐
- Hadoop学习(4)-- MapReduce
MapReduce是一种用于大规模数据集的并行计算编程模型,由Google提出,主要用于搜索领域,解决海量数据的计算问题.其主要思想Map(映射)和Reduce(规约)都是从函数是编程语言中借鉴而来的 ...
- PostgreSQL Replication之第十二章 与Postgres-XC一起工作(6)
12.6 添加节点 Postgres-XC允许您在那个过程中的任何一个时间点添加新的服务器到计划中.所有您需要做的是按照我们之前演示的设置一个节点,并在 控制器上调用CREATE NODE.然后,该系 ...
- escape()、encodeURI()、encodeURIComponent() difference
escape() 方法: 采用ISO Latin字符集对指定的字符串进行编码.所有的空格符.标点符号.特殊字符以及其他非ASCII字符都将被转化成%xx格式的字符编码(xx等于该字符在字符集表里面的编 ...
- [转] java编程规范
原文链接: 资料推荐--Google Java编码规范 之前已经推荐过Google的Java编码规范英文版了: http://google-styleguide.googlecode.com/svn/ ...
- Python学习总结10:获取shell输出结果
Python中获取shell命令的输出结果的常见方法如下几种: 1. import subprocess output = subprocess.Popen(['ls','-l'],stdout=su ...
- android课程表的实现
//图片下方的码段主要实现了课程表所要显示的基本布局,采用ondraw的方法. //别的内容可以根据自己兴趣添加,下面是本人做的,仅供参考. package com. ...
- codeforces 446C DZY Loves Fibonacci Numbers(数学 or 数论+线段树)(两种方法)
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 ...
- ARM 寄存器的介绍
ARM 寄存器 31个通用, 32个程序状态寄存器 怎么算的呢: (R0--R15) 16 + 7 + 8 =31 通用 程序状态寄存器: 6 个 共 37 个. 不分组寄存器: ...
- php 迭代器
迭代器(Iterator)模式,又叫做游标(Cursor)模式.GOF给出的定义为:提供一种方法访问一个容器(container)对象中各个元素,而又不需暴露该对象的内部细节. 百度百科: http: ...
- Oracle11.2新特性之listagg函数 (行列转换)
SELECT regexp_substr('公司1,贵公司2', '[^,]+', 1, LEVEL, 'i') FROM dualCONNECT BY LEVEL <= length('公司1 ...