iOS~静态库开发

摘要:
在我们的工作中,我们经常需要制作自己的静态库,并封装一些模块以供共享。

在工作中,我们常常需要制作自己的静态库,封装一些模块,以便共享使用。

多架构(Multi-Architecture)编译

iOS app需要在许多不同的CPU架构下运行:

  • arm7: 在最老的支持iOS7的设备上使用

  • arm7s: 在iPhone5和5C上使用

  • arm64: 运行于iPhone5S的64位 ARM 处理器 上

  • i386: 32位模拟器上使用

  • x86_64: 64为模拟器上使用

静态库有真机和模拟器之分,一般可以生产通用静态库

http://www.cocoachina.com/ios/20150226/11182.html

http://www.cocoachina.com/ios/20141126/10322.html

http://www.cocoachina.com/ios/20150127/11022.html

http://blog.csdn.net/pjk1129/article/details/7255163

使用Xcode7.0.1 编译出的静态库

真机支持armv7 arm64 默认居然不带armv7s

模拟器支持x86_64

bogon:~ shenlong$ lipo -info /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphoneos/libstatic_test.a
Architectures in the fat file: /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphoneos/libstatic_test.a are: armv7 arm64
bogon:~ shenlong$ lipo -info /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphonesimulator/libstatic_test.a
input file /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphonesimulator/libstatic_test.a is not a fat file
Non-fat file: /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphonesimulator/libstatic_test.a is architecture: x86_64

合并2个静态库

bogon:~ shenlong$ lipo -info /Users/shenlong/Desktop/libMyStatic.a
Architectures in the fat file: /Users/shenlong/Desktop/libMyStatic.a are: armv7 x86_64 arm64

目前只支持 armv7  arm64 x86_64 不支持armv7s(iPhone5 iPhone5C)

下图在CPU框架中添加支持armv7s

25.png

如上图,框架中添加armv7s后

bogon:~ shenlong$ lipo -info /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphoneos/libstatic_test.a
Architectures in the fat file: /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphoneos/libstatic_test.a are: armv7 arm64 armv7s

再次合并

lipo -create /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphoneos/libstatic_test.a /Users/shenlong/Library/Developer/Xcode/DerivedData/static_test-dsdhaafkwbcsczelhkvovfhbaijl/Build/Products/Debug-iphonesimulator/libstatic_test.a -output /Users/shenlong/Desktop/libMyStatic.a

查看支持框架

bogon:~ shenlong$ lipo -info /Users/shenlong/Desktop/libMyStatic.a
Architectures in the fat file: /Users/shenlong/Desktop/libMyStatic.a are: armv7 armv7s x86_64 arm64

这样就完全支持armv7 armv7s arm64 所有的CPU框架了。

就是这样!

免责声明:文章转载自《iOS~静态库开发》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇哈弗曼编码EasyUI DataGrid动态修改列标题下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

iOS开发常用的10个Xcode插件

原文连接:http://ios.jobbole.com/80697/ 1. XcodeColors:给 Xcode 控制台添加颜色 2. XToDo:这个插件不仅高亮 TODO、 FIXME、 ???,还高亮 !!!  注释 3. Backlight:高亮当前正在编辑的那一行 4. CocoaPods 插件:依赖管理助手 5. ACCodeSnippet...

ios开发 打开第三方app

ios打开第三方应用比较简单 第三方应用的info.plist设置 在项目里面添加代码: 1 #import "ViewController.h" 2 3 @interface ViewController () 4 5 @end 6 7 @implementation ViewController 8 9 - (void)vi...

ios开发 静态库制作

IOS程序是由Objective-c语言构成,而是Objective-c语言中每一个类又分成 .h .m 文件。静态库可以将这些程序的类封装成一个.a文件,第三方应用程序只需要拿到这个.a文件和代码对应的.h文件即可使用静态库中封装的方法。总的来说IOS静态库适合去制作第三方提供的SDK,废话不多说了我们直接进正题。 制作静态库 代码如下 1 #i...

在Visual Studio中使用MonoTouch开发iOS应用程序(下):开发体验 狼人:

对于熟悉.NET程序员来说,编写iOS应用程序的最佳选择自然是MonoTouch。在上一篇文章里,我们已经在Mac OS X上安装了MonoTouch开发环境,并已经能够在Mac OS X和Windows之间共享文件。现在我们就可以来简单体验一下,如何使用Visual Studio,Interface Builder以及少量的MonoDevelop来开发一...

iOS开发时间戳与时间,时区的转换,汉字与UTF8,16进制的转换

原文:http://blog.sina.com.cn/s/blog_68661bd80101njdo.html //获取当前系统的时间戳+(long)getTimeSp{    long time;    NSDate *fromdate=[NSDate date];    time=(long)[fromdate timeIntervalSince197...

iOS开发UI篇—Button基础

iOS开发UI篇—Button基础 一、简单说明 一般情况下,点击某个控件后,会做出相应反应的都是按钮 按钮的功能比较多,既能显示文字,又能显示图片,还能随时调整内部图片和文字的位置 二、按钮的三种状态 normal(普通状态) 默认情况(Default) 对应的枚举常量:UIControlStateNormal highlighted(高亮状态) 按钮被...