转载地址: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. Sqoop -- 用于Hadoop与关系数据库间数据导入导出工作的工具

    Sqoop是一款开源的工具,主要用于在Hadoop相关存储(HDFS.Hive.HBase)与传统关系数据库(MySql.Oracle等)间进行数据传递工作.Sqoop最早是作为Hadoop的一个第三 ...

  2. ajax请求后加额外的数据

    $.ajax({ cache: true, type: "POST", url:"${ctx!}/bus/trail/getTrailInfoById", da ...

  3. MYBATIS报ORA-01745: 无效的主机/绑定变量名 异常

    异常:Cause: java.sql.SQLSyntaxErrorException: ORA-01745: 无效的主机/绑定变量名 原因,sql语句中,两个填充变量间没有写逗号.

  4. php:mysqli扩展

    mysqli功能概述:http://php.net/manual/zh/mysqli.summary.php 代码(基本的用法):貌似可以防止sql注入 $root = "root" ...

  5. Git_Commands

  6. IntelliJ IDEA 显示行号方法

    设置方法如下:   File->Settings->Editor->General->Appearence->Show Line Number  

  7. Compile Sources 和 Copy Bundle Resources的区别

    Compile Sources主要存放.m文件 Copy Bundle Resources 主要存放xib plist bundle js 文件

  8. Swift实战-小QQ(第1章):QQ登录界面

    1.新建小QQ项目 2.将所需用到的图片资源(resource)文件夹,添加到项目中.并新建一个登录页面:LoginViewController.swift 3.修改LoginViewControll ...

  9. java基础(59):Eclipse把自动括号匹配改成C++那样的(强迫症,没办法)

    在Eclipse开发环境下依次选择: 1.Windows->Preferences->Java->Code Style->Formatter: 2.在Active Profil ...

  10. 常用的sql函数

    常用的sql函数 concat('hello','world') 结果:helloworld  作用:拼接 substr('helloworld',1,5)      hello           ...