lipo

2021-08-18  本文已影响0人  上发条的树

lipo 工具用于查看、提取、合并、拆分二进制文件(Mach-O)的CPU指令架构。
从下面可看出,是Xcode自带工具。

% lipo
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: one of -create, -thin <arch_type>, -extract <arch_type>, -remove <arch_type>, -replace <arch_type> <file_name>, -verify_arch <arch_type> ... , -archs, -info, or -detailed_info must be specified
usage: lipo <input_file> <command> [<options> ...]
  command is one of:
    -archs
    -create
    -detailed_info
    -extract <arch_type> [-extract <arch_type> ...]
    -extract_family <arch_type> [-extract_family <arch_type> ...]
    -info
    -remove <arch_type> [-remove <arch_type> ...]
    -replace <arch_type> <file_name> [-replace <arch_type> <file_name> ...]
    -thin <arch_type>
    -verify_arch <arch_type> ...
  options are one or more of:
    -arch <arch_type> <input_file>
    -hideARM64
    -output <output_file>
    -segalign <arch_type> <alignment>

使用方式,例如

// 对于 .framework
lipo -info xxx.framework/xxx
// 对于 .a
lipo -info xxx.a

1、查看支持的平台架构:

lipo -info xxx.framework/xxx
真机 模拟器

2、合并平台架构

lipo -create xxx.framework/xxx yyy.framework/yyy -output zzz

将支持真机和模拟器文件进行合并:


合并

3、移除指定平台架构

lipo xxx.framework/xxx -remove x86_64 -out zzz
移除指定架构

3、提取指定平台架构

lipo xxx.framework/xxx -thin armv7 -output 
提取指定架构

4、查看 fat file 详细信息
注意:-detailed_info 此命令只对包含多个指令架构的文件有效。

lipo -detailed_info xxx.framework/xxx
-detailed_info

注意

上面我们通过 lipo 对 .framework 中的 Mach-O 文件进行操作,如果要使用操作后的 Mach-O 文件,要确保放回 .framework 中的 Mach-O 文件必须保持原来的文件名。


文件名保持一致

看懂请随手点赞,朋友们!🌹🌹🌹

上一篇 下一篇

猜你喜欢

热点阅读