标签:
在引入第三方lib(.a)库时,经常会由于第三方lib库中又引入同你现有工程相同的开源代码而造成.o冲突。我想说的是像这种开源的使用率很高的源代码本不应该包含在lib库中,就算是你要包含那也要改个名字是吧。不过没办法现在人家既然包含,我们就只有想办法分离了。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
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
标签:
原文地址:http://blog.csdn.net/lin1986lin/article/details/45096553