zoukankan      html  css  js  c++  java
  • 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框架了。

    就是这样!

  • 相关阅读:
    企业微信中如何屏蔽另外一个企业的消息
    国际商标注册里面的头头道道
    如何使用charles,常见的charles功能
    Win8中GridVIew千变万化——绑定分组数据
    Win8中ListBox的ScrollIntoView方法失效
    一起零基础通过Nosql考试~~
    Ubuntu部署ros小龟爬爬实例
    学习算法是件怎样的事
    Centos7配置Python3.10.1
    基于Centos7、PHP7.4环境部署wordpress
  • 原文地址:https://www.cnblogs.com/kevingod/p/4977151.html
Copyright © 2011-2022 走看看