iOS~静态库开发
2015-11-19 11:49
357 查看
在工作中,我们常常需要制作自己的静态库,封装一些模块,以便共享使用。
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
如上图,框架中添加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框架了。
就是这样!
多架构(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
如上图,框架中添加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使用Xcode开发如何避免与解决冲突-不区分svn和git-100%保证你远离冲突
- iOS CLLocationManager定位,IOS8注意
- iOS post请求 (普通请求)
- 芒果iOS开发之通过RGB值设置背景颜色
- IOS获取经度纬度
- [IOS 开发] @IBDesignable @IBInspectable
- ios开发笔记-7-bug解决
- iOS标准时间与时间戳相互转换
- iOS 9的 Core Image新滤镜
- iOS中几种数据持久化方案
- iOS中scrollsToTop小结
- iOS数据类型
- 好的文章收藏
- iOS 点击检测版本更新
- iOS 开发实用工具
- iOS中@class #import #include 简介
- iOS9适配 《AdaptationTips》
- Nagios+Cacti整合
- 14 款好用的 iOS 开发工具
- 友盟SDK应用(二)------url分享