iOS静态库的制作与引用
【iOS静态库的制作与引用】
1、Configuring Exported Headers
To configure which headers are exported to clients, select your library project to open the project editor, select the library target to open the target editor, and select the build phases tab. If your library target has a “Copy Headers” build phase, you should delete it; copy headers build phases do not work correctly with static library targets when performing the “Archive” action in Xcode.
Next you will add a Copy Files build phase for exporting your headers. New static library targets created with Xcode 4.4 or later will come with an appropriately-configured Copy Files phase for headers, so you should check to see if you already have one before creating one. If you do not, press “Add Build Phase” at the bottom of the target editor and choose to “Add Copy Files.” Disclose the new Copy Files build phase and set the Destination to “Products Directory". Set the Subpath to include/${PRODUCT_NAME}. This will copy files into a folder named after your library (taken from the PRODUCT_NAME build setting), inside a folder named include, inside your built products directory. The include folder inside a build products directory is in the default header search path for applications, so this is an appropriate place to put header files. Putting header files inside a folder named after your PRODUCT_NAME will allow you to segregate library headers by library name, for clarity.
Now select the headers in your static library project which clients of that library will need to import and drag them into the new Copy Files phase. These headers will now be exported to the appropriate location inside your built products directory when you build. Any time you add new headers to your static library which clients will need to import, you should add them to this phase.

2、Linking Against Your Library
Find the “Other Linker Flags” build setting. Add the flag -ObjC to this build setting’s value if it is not already present. This flag will tell the linker to link all Objective-C classes and categories from static libraries into your application, even if the linker can’t tell that they are used. This is needed because Objective-C is a dynamic language and the linker can’t always tell which classes and categories are used by your application code.

3、Importing Library Headers
Your library’s headers are automatically included in your application’s header search path, as they are inside the built product directory’s include directory. Since your library puts its headers in a further directory named after its PRODUCT_NAME build setting, you need to include that directory in your include or import statements when importing that library’s headers. In your application’s source code you should import your library’s headers like this:
#import "LibraryName/HeaderName.h"
4、其它要点
1)点添加一个.a后,该.a的路径会被自动加入到LibrarySearchPaths,如:

同时LibrarySearchPaths目录下的include目录也会被作为头文件搜索路径。
iOS静态库的制作与引用的更多相关文章
- iOS 静态库的制作
按照公司的想法 要开发一款SDK,于是就抽空学习一下静态枯的制作过程. 在IOS中有静态库和动态库的区分,下面我们就来详细介绍一下. 一.静态库和动态库的详细介绍. 我们平时的工程中或多或少都要引入第 ...
- iOS静态库.Framework制作
首先要解释一下什么是库,库(Library)其实就是一段编译好的二进制代码,加上头文件就可以供别人使用,一般会有两种情况要用到库: 某些代码需要给别人使用,但是我们不希望别人看到源码,就需要以库的形式 ...
- iOS开发中静态库之".framework静态库"的制作及使用篇
iOS开发中静态库之".framework静态库"的制作及使用篇 .framework静态库支持OC和swift .a静态库如何制作可参照上一篇: iOS开发中静态库之" ...
- iOS静态库.a文件制作和导入使用
iOS静态库.a文件制作: 1.新建Cocoa Touch Static Library工程 新建工程 - 选择iOS-FrameWork&Libary,选择 Cocoa Touch Stat ...
- iOS : 静态库制作
一.静态库简介 1. 什么是库? 库 就是程序代码的集合, 是共享程序代码的一种方式 2. 库的分类? 开源库 公开源代码, 能看到具体实现 例如MJExtension, MJRefresh, AFN ...
- iOS开发之静态库的制作
当你需要和别人分享代码,但又不想让别人看到你内部的实现时就需要制作静态库,通常用于第三方SDK 下面就分享一下制作静态库(.a)的过程: 1.打开Xcode,新建workspace 2.随便给work ...
- iOS - 静态库的创建与使用
在日常项目开发中,不论是为了两个公司项目上的业务交流还是为了减少项目的编译时间,有的时候我们会把项目中的私密内容打包成静态库,或者是把项目中变动较少一部分打包成静态库以便提高编译效率,那么下面我们就来 ...
- IOS静态库
如何在Xcode中创建C++静态库 http://jingyan.baidu.com/article/03b2f78c111fca5ea237ae26.html iOS 如何创建和使用静态库 http ...
- iOS 静态库,动态库与 Framework
iOS 静态库,动态库与 Framework 静态库与动态库的区别 首先来看什么是库,库(Library)说白了就是一段编译好的二进制代码,加上头文件就可以供别人使用. 什么时候我们会用到库呢 ...
随机推荐
- 视图框架:Spring MVC 4.0(2)
在<springMVC4(7)模型视图方法源码综合分析>一文中,我们介绍了ModelAndView的用法,它会在控制层方法调用完毕后作为返回值返回,里面封装好了我们的业务逻辑数据和视图对象 ...
- 如何在JM8.6编码端提取QDCT?
毫无疑问,编码端的QDCT和解码端的QDCT完全相同,下面从编码端提取QDCT. 为简便起见,仅提取第一帧第一个宏块第一个4*4块的QDCT.JM8.6编码器最核心的编码函数是encode_one_m ...
- Arcgis for Javascript之统计图的实现
首先,截个图给大家看看效果: 初始化状态 放大后的状态 点击选中后的状态 如上图所示,一般的涉及到的地图的统计涉及到上述所展示的三个状态:1.初始化状态:2.缩放后的状态:3.点击选中显示详情状态.第 ...
- ng 自定义过滤器的创建和使用
过滤器的本质就是一个方法,参数就是输入的值以及给过滤器指定的参数,返回值就是处理后要显示的值. ①过滤器创建var app = angular.module();app.filter(‘名称’,fun ...
- NOIP2011 观光公交 加强版
传送门 题目大意 给定从左到右的$n$个车站以及两两之间通行的需要的时间. 有$m$个人,第$i$个人会在$T_i$时刻出现在$a_i$车站,目的地是$b_i$. 一辆车第$0$时刻出现在一号站台,从 ...
- freemarket使用自定义标签 注解【项目实际使用】
页面达到效果 [主html页面代码] <!-- 合作单位 版块 -->[#include 'inc_project_succ_coo.html'/]['inc_project_succ_c ...
- SSH框架(2)
个人分类: Java面试 Struts 谈谈你对Struts的理解. 答: 1.struts是一个按MVC模式设计的Web层框架,其实它就是一个大大的servlet,这个Servlet名为Acti ...
- Windows 7 扩展玻璃效果(Aero Glass)
转自:http://www.cnblogs.com/gnielee/archive/2010/10/04/windows7-extend-aero-glass.html Windows 7 操作系统默 ...
- codevs4189字典
沙茶 题目大意:求某一个字符串前缀有没有在n个字符串前缀里出现过 题解:Trie树 查询前缀有没有出现 代码: //codevs4189 #include<iostream> #inclu ...
- 洛谷 P1292 倒酒
题目描述 Winy是一家酒吧的老板,他的酒吧提供两种体积的啤酒,a ml和b ml,分别使用容积为a ml和b ml的酒杯来装载. 酒吧的生意并不好.Winy发现酒鬼们都非常穷.有时,他们会因为负担不 ...