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)说白了就是一段编译好的二进制代码,加上头文件就可以供别人使用. 什么时候我们会用到库呢 ...
随机推荐
- JSP的三大指令
三大指令:page指令.include指令和taglib指令. page指令: * import:等同与import语句 <%@ page import="java.util.*& ...
- Android应用接入第三方登陆之新浪微博
众所周知,移动互联网在这几年经历了蓬勃发展,到目前为止,移动互联网发展仍然很强劲.其中移动设备系统以android占据主导地位,之前是加拿大的黑莓系统占据主导,但后来随着android系统的问世,黑莓 ...
- boost 部分编译
完整编译boost库需要很长时间,而且我们不一定会用到所有的库. 那么如何只编译只需要的库呢? 解压boost源码,进入解压后的目录 ./bootstrap.sh生成bjam ./bjam --bui ...
- [leetcode]_Interleaving String
下午去蹭了一发新浪的笔试. 炒鸡多的网络基础知识,总共18道题,就写了8道左右吧,剩下的全是网络知识,这部分抽时间至少过一过. 其中一道算法题,回来跟嘟嘟商量,才发现是leetcode上的原题,连ex ...
- HihoCoder - 1615矩阵游戏II(贪心)
矩阵游戏II 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个NxN的整数矩阵,小Hi每次操作可以选择两列,将这两列中的所有数变成它的相反数. 小Hi可以进行任意 ...
- EL表达式可以直接放在url的“ ”里面
<div class="hc-prm-search search flr"> <form action="/userCenter/projectInfo ...
- bzoj 4448 情报传递
Written with StackEdit. Description 奈特公司是一个巨大的情报公司,它有着庞大的情报网络.情报网络中共有\(n\)名情报员.每名情报员能有若干名(可能没有)下线,除\ ...
- Cocos2d-x -自己定义动作 圆周运动
原文地址:http://blog.csdn.net/u012945598/article/details/17605409 在之前的文章中我们以前讲过Cocos2d-x中的各种动作的用法,我们先来简单 ...
- myeclipse按.自动提示方法
第一步:菜单Window->Preferences->Java->Editor->Content Assist->Enable auto activation 选项要打勾 ...
- 为IIS Host ASP.NET Web Api添加Owin Middleware
将OWIN App部署在IIS上 要想将Owin App部署在IIS上,只添加Package:Microsoft.OWIN.Host.SystemWeb包即可.它提供了所有Owin配置,Middlew ...