• 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框架了。

    就是这样!

  • 相关阅读:
    oracle 数据库、实例、服务名、SID
    查看oracle数据库服务器的名字
    oracle表复制
    Oracle 备份、恢复单表或多表数据步骤
    如何查询一个表中有哪些列全为空
    mysql当查询某字段结果为空并赋值
    NoSQL初探之人人都爱Redis:(1)Redis简介与简单安装
    《大型网站技术架构》读书笔记四:瞬时响应之网站的高性能架构
    《大型网站技术架构》读书笔记三:大型网站核心架构要素
    《大型网站技术架构》读书笔记二:大型网站架构模式
  • 原文地址:https://www.cnblogs.com/kevingod/p/4977151.html
Copyright © 2020-2023  润新知