iOS开发中 workspace 与 static lib 工程的联合使用
来源:互联网 发布:js正则表达式 i 编辑:程序博客网 时间:2024/06/01 12:09
在iOS开发中,其实workspace的使用没有完全发挥出来,最近做了一些研究,也想把之前写过的代码整理下,因为iOS里面的布局方式,交互方式也就那么几种。所以,整理好了之后,更能快捷开发,而且能够形成积累。所以把常用的东西封装成lib文件。
我自己的实施过程如下,同时会穿插一些自己参考的文章的链接或者方法。主要参考链接:
http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/#set_the_installation_directory
1、新建一个文件夹,然后新建一个workspace, 将这个workspace放置在这个文件夹中,创建workspace的过程与创建工程类似。
如下是创建的截图:
2、在这个workspace中创建一个static lib 工程
3、在workspace中创建一个empty project
4、工程创建完成,后面就有很多事情要做了,配置工程,empty project能够使用 static lib中的代码。
首先,在empty project 中的Build Phases->Link Binary with Libraries 中添加 libTTStyles.a
然后在 empty project 的Build Settings->User Header Search Paths 里面添加"$(BUILT_PRODUCTS_DIR)” 和“$(BUILT_PRODUCTS_DIR)/static_library_name”两个选项,才能在编译的时候搜索到相关的头文件
然后,在static lib工程的 Other Linker Flags 中添加-ObjC, -all_load, -force_load 这三个选项,至少添加前两个,不然会报错,
这个是Xcode里面的一个bug, Three20里面有这么一段代码:
1 #define TT_FIX_CATEGORY_BUG(name) @interface TT_FIX_CATEGORY_BUG_##name @end \2 @implementation TT_FIX_CATEGORY_BUG_##name @end
就是为了解决,static lib中的category无法引用 的问题,添加了一个同名的空类。上面最开始的链接里面有这个问题的解答:
The “User Header Search Paths” setting defines the headers available as quoted imports (eg “#import “MyLibraryClass.h”) while the “Header Search Paths” setting defines those headers available as bracketed imports (eg “#import ). I’ve found that Xcode will only autocomplete header names in the quoted form so I always add libraries to the user header search path even though, from my project’s perspective, they might be more appropriate as system level (angle bracketed) libraries.When using a static library which includes categories we will also have to add the “-ObjC” flag to the “Other Linker Flags” build setting. This will force the linker to load all objective-c classes and categories from the library. If the library contains only categories “-all_load” or “-force_load” may be needed as well. See Technical Q&A QA1490 for a more detailed explanation of these settings.
5、配置工程的编译选项,控制编译工程之间的依赖关系。
在,TTProject的 scheme manage里面添加之前建立的lib文件,编译TTProjects的时候,就会先编译 statib lib的内容,然后再编译自身工程
At this point Xcode should have detected this implicit dependency between our app’s project and the static library’s project and have automatically configured our schemes correctly. Unfortunately I haven’t found this to be the case in practice. Instead we will have to edit our current scheme and add the static library’s build target before our app’s build target.
转自:http://www.cnblogs.com/easonoutlook/p/3203306.html
- iOS开发中 workspace 与 static lib 工程的联合使用
- 手动创建WorkSpace方式的iOS多工程联合编译包含Static Library
- 创建WorkSpace方式的iOS多工程联合编译包含Static Library
- iOS开发过程中 const 与 static 的使用
- xcode4的workspace里各lib工程与app工程联编之runscript简介
- xcode4的workspace里各lib工程与app工程联编之runscript简介
- iOS 静态类库项目的建立与使用(workspace)
- iphone ios 如何在xcode中使用静态库(static lib),并能调试
- iphone ios 如何在xcode中使用静态库(static lib),并能调试
- keil中lib的生成与使用
- iOS开发中,在一般的ViewController中使用static cell
- 在iOS开发中使用静态库(Static Library)
- 在iOS开发中使用静态库(Static Library)
- 【iOS】Workspace使用
- iOS开发中 ARC工程使用非ARC文件/非ARC工程使用ARC文件的解决办法
- iOS开发中 ARC工程使用非ARC文件/非ARC工程使用ARC文件的解决办法
- 工程上*.lib与*.dll的区别
- ASP.NET 2.0中GridView与DetailsView的联合使用
- 小议游戏服务器的消息组包
- Android 的Margin和Padding Layout_weight属性
- ORACLE数据库:ORA-28000:the account is locked
- JS日期格式判断
- Java设计模式学习(一)
- iOS开发中 workspace 与 static lib 工程的联合使用
- LINUX下搭建FTP服务器
- Log4Net使用指南
- 关于IOS7中scrollview中subviews的frame看起不正确的问题
- c++的构造函数
- 一剪梅,隐约着一树温柔
- makefile中的patsubst .
- listView中定义GridView绑定失败
- 算法时间复杂度