如何在 iOS 中确定静态库的特定切片的大小

How to determine size of a specific slice of a static library in iOS

我的 iOS 项目中有一个静态库,其中包含 4 种架构的切片。我可以使用以下命令确定静态库的架构切片组件:

$ file myStaticLib.a
myStaticLib.a: Mach-O universal binary with 4 architectures
myStaticLib.a (for architecture armv7):  current ar archive random library
myStaticLib.a (for architecture i386):   current ar archive random library
myStaticLib.a (for architecture x86_64): current ar archive random library
myStaticLib.a (for architecture arm64):  current ar archive random library

我想确定特定切片(例如 arm64)的 大小。我该怎么做?

使用带有 -detailed_info 标志的 lipo 命令,您可以确定特定切片的大小(以及其他详细信息)。用法如下:

$ lipo -detailed_info myStaticLibrary.a

Fat header in: myStaticLib.a
fat_magic 0xcafebabe
nfat_arch 4
architecture armv7
    cputype CPU_TYPE_ARM
    cpusubtype CPU_SUBTYPE_ARM_V7
    offset .......
    size .......
    align 2^2 (4)
architecture i386
    cputype CPU_TYPE_I386
    cpusubtype CPU_SUBTYPE_I386_ALL
    offset .......
    size .......
    align 2^2 (4)
architecture x86_64
    cputype CPU_TYPE_X86_64
    cpusubtype CPU_SUBTYPE_X86_64_ALL
    offset .......
    size .......
    align 2^2 (4)
architecture arm64
    cputype CPU_TYPE_ARM64
    cpusubtype CPU_SUBTYPE_ARM64_ALL
    offset .......
    size .......
    align 2^2 (4)