转载地址: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 解析的更多相关文章

  1. 在 Mac OS X 上创建的 .NET 命令行程序访问数据库 (使用Entity Framework 7 )

    var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...

  2. 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 ...

  3. 出现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 ...

  4. Mac OS X 背后的故事

    Mac OS X 背后的故事 作者: 王越  来源: <程序员>  发布时间: 2013-01-22 10:55  阅读: 25840 次  推荐: 49   原文链接   [收藏]   ...

  5. 在 Mac OS X 上安装 TensorFlow

    在 Mac OS X 上安装 TensorFlow 这个文档说明了如何在 Mac OS X 上安装 TensorFlow. 注意:从 1.2 版本开始,在 Mac OS X 上 TensorFlow ...

  6. 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. ...

  7. Mac OS X 上安装 ASP.NET 5

    在Mac OS X Yosemite 10.10.3 中搭建第一个 ASP.NET 5 Web 项目 终于有时间在 Mac 上安装一下 ASP.NET 5,网上有许多教程,但是多数的时间比较早了,版本 ...

  8. [.net 面向对象程序设计深入](5)MVC 6 —— 构建跨平台.NET开发环境(Windows/Mac OS X/Linux)

    [.net 面向对象程序设计深入](5)MVC 6 —— 构建跨平台.NET开发环境(Windows/Mac OS X/Linux) 1.关于跨平台 上篇中介绍了MVC的发展历程,说到ASP.NET ...

  9. Mac OS平台下应用程序安装包制作工具Packages的使用介绍

    一.介绍 Windows下面开发好的应用程序要进行分发时有很多打包工具可供选择,如Inno Setup, InstallShield, NSIS, Advanced Installer, Qt Ins ...

随机推荐

  1. lua cURL使用笔记

    cURL cURL是 URL命令行工具, 即 command URL, 可以通过命令行模拟各种应用协议的发包, 包括FTP HTTP HTTPS, 官方网站 http://curl.haxx.se/ ...

  2. memwatch内存泄露检测工具

    工具介绍 官网 http://www.linkdata.se/sourcecode/memwatch/ 其功能如下官网介绍,挑选重点整理: 1. 号称功能: 内存泄露检测 (检测未释放内存, 即 动态 ...

  3. IIS URL Rewrite redirect from one Domain to another

    IIS URL Rewrite enables Web administrators to create powerful rules to implement URLs that are easie ...

  4. checkbox判断选中

    $("input[type='checkbox']").is(':checked')

  5. DG - 开启Active Data Guard

    在配置active data guard之前,phycial standby必须处于以下两个状态之一: (1)standby处于mount状态,并且redo apply正在运行中 (2)standby ...

  6. oracle随机取数据

    select * from (select rownum,KEYWORD, CATEGORY,CREATE_DATE,UPDATE_DATE from (select * from knet_keyw ...

  7. 夺命雷公狗---DEDECMS----6快速入门之总结篇

    我们dedecms四大表分别是: dede_channeltype(模型表) dede_arctype(栏目表) dede_archives(文章主表) dede_addonXXXX(附加表) 使用d ...

  8. hibernate笔记02

  9. 5 Best Automation Tools for Testing Android Applications

    Posted In | Automation Testing, Mobile Testing, Software Testing Tools   Nowadays automated tests ar ...

  10. ImagXpress中如何修改Alpha通道方法汇总

    ImagXpress支持处理Alpha通道信息来管理图像的透明度,Alpha通道支持PNG ,TARGA和TIFF文件,同时还支持BMP和ICO文件.如果说保存的图像样式不支持Alpha通道,就将会丢 ...