1.依次查看lib庫所支持的框架類型。i386:模擬器,armv7:iphone4,armv7s:iphone5,iphone5s,arm64:iphone6,iphone6p
1 robindeMacBook-Pro-2:testlib robin$ lipo -info lib.a 2 Architectures in the fat file: lib.a are: armv7 armv7s arm64 3 robindeMacBook-Pro-2:testlib robin$ fat file:表示該lib庫文件中合並了多個框架的lib庫,這裡合並的有armv7 armv7s arm64。如果同時合並了模擬器的lib庫,這裡還會有i386的標識。
1 robindeMacBook-Pro-2:testlib robin$ lipo -extract_family armv7 -output lib_armv7.a lib.a 2 robindeMacBook-Pro-2:testlib robin$ lipo -info lib_armv7.a 3 Architectures in the fat file: lib_armv7.a are: armv7 armv7s 查看發現分離出來的lib_armv7.a仍舊是fat文件,只有Non-fat文件才可以分離.o。所以仍然需要進行進一步分離。
1 robindeMacBook-Pro-2:testlib robin$ lipo lib_armv7.a -thin armv7 -output lib_final_armv7.a 2 robindeMacBook-Pro-2:testlib robin$ lipo lib_armv7.a -thin armv7s -output lib_final_armv7s.a 3 robindeMacBook-Pro-2:testlib robin$ lipo -info lib_final_armv7.a 4 input file lib_final_armv7.a is not a fat file 5 Non-fat file: lib_final_armv7.a is architecture: armv7 6 robindeMacBook-Pro-2:testlib robin$ lipo -info lib_final_armv7s.a 7 input file lib_final_armv7s.a is not a fat file 8 Non-fat file: lib_final_armv7s.a is architecture: armv7s 復制代碼 此時分離出來的已經是Non-fat文件了,才可進行分離.o。
arm64是iOS系統最新增加的框架,按照分離armv7,armv7s的方式無論如何都無法分離出arm64版本的Non-fat文件,經過多次試驗發現可以通過下面命令直接分離。
1 robindeMacBook-Pro-2:testlib robin$ lipo lib.a -thin arm64 -output lib_final_arm64.a 2 robindeMacBook-Pro-2:testlib robin$ lipo -info lib_final_arm64.a 3 input file lib_final_arm64.a is not a fat file 4 Non-fat file: lib_final_arm64.a is architecture: arm64
1 robindeMacBook-Pro-2:testlib robin$ lipo -extract_family i386 -output lib_final_i386.a lib.a 2 robindeMacBook-Pro-2:testlib robin$ lipo -info lib_final_i386.a 3 input file lib_final_i386.a is not a fat file 4 Non-fat file: lib_final_i386.a is architecture: i386
5.分離目標文件.o
1 robindeMacBook-Pro-2:testlib robin$ mkdir armv7 2 robindeMacBook-Pro-2:testlib robin$ cd armv7 3 robindeMacBook-Pro-2:armv7 robin$ ar -x ../lib_final_armv7.a 其他同理
1 robindeMacBook-Pro-2:arm64 robin$ libtool -static -o ../libarmv7.a *.o 其他同理
1 robindeMacBook-Pro-2:testlib robin$ lipo -create -output libs.a libarmv7.a libarmv7s.a libarm64.a 2 robindeMacBook-Pro-2:testlib robin$ lipo -info libs.a 3 Architectures in the fat file: libs.a are: armv7 armv7s arm64