iOS开发第三方库之间出现duplicate symbol时的处理方法

今天做项目遇到第三方库与当前项目代码冲突到问题。发现是第三方库中使用了GDataXMLNode,而我的APP项目中的微信开发部分也用到了GDataXMLNode。这就造成了冲突,产生了duplicate symbol错误。
我首先尝试删了微信中的GDataXMLNode.h和GDataXMLNode.m,但是不行,因为微信开发的代码中,包含了GDataXMLNode.h。
后来在网上找到了解决方法,那就是把第三方库中的GDataXMLNode.o删掉。

1、查看库所包含的CPU架构

打开终端输入如下命令:
cd /Users/fww/Desktop/temp
lipo -info temp.a
输出结果:
Architectures in the fat file: temp.a are: i386 x86_64 armv7 arm64

2、 分离不同架构的静态库

也就是说这里将会从temp.a中分离出i386 、x86_64、 armv7 、arm64 四个架构下的静态库,分别取名temp_i386.a,temp_x86_64.a,temp_armv7.a,temp_arm64.a:
在终端中继续输入如下命令:
lipo -extract_family i386 -output temp_i386.a temp.a
lipo -extract_family x86_64 -output temp_x86_64.a temp.a
lipo -extract_family armv7 -output temp_armv7.a temp.a
lipo -extract_family arm64 -output temp_arm64.a temp.a

验证:

lipo -info temp_i386.a
input file temp_i386.a is not a fat file
Non-fat file: temp_i386.a is architecture: i386

lipo -info temp_x86_64.a
input file temp_x86_64.a is not a fat file
Non-fat file:temp_x86_64.a is architecture: x86_64

lipo -info temp_armv7.a
input file temp_armv7.a is not a fat file
Non-fat file: temp_armv7.a is architecture: armv7

lipo -info /Users/fww/Desktop/temp/temp_arm64.a
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can’t figure out the architecture type of: temp_arm64.a
说明:我第一次这样做的时候,是成功的,我想再做一次验证的时候,这一步却始终过不去,目前还没找到原因。如果你有幸分离出的不同架构下的静态库都验证成功的话,继续往下吧。

3 删除冲突的库

ar -d temp_i386.a GDataXMLNode.o
ar -d temp_x86_64.a GDataXMLNode.o
ar -d temp_armv7.a GDataXMLNode.o
ar -d temp_arm64.a GDataXMLNode.o
ar: temp_arm64.a: Inappropriate file type or format
说明:因为前三个验证都是没问题的,所以命令执行后,你终端不会显示任何信息,而且你可以观察前后的文件大小,发现文件确实变小了,可以基本认为是成功了。而第四个因为我这里有问题,所以删除库的时候会提示错误,暂时无解。

4 合并为新的库

删除冲突的库之后,将不同架构下的静态库再重新合并起来,取名:temp_new.a
lipo -create -output temp_new.a temp_i386.a temp_x86_64.a temp_armv7.a temp_arm64.a
由于arm64有问题,所以这个合并也是会报错的:
atal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can’t figure out the architecture type of: temp_arm64.a

总结:方法就是这样的,中途出的错误暂时没找到解决方法。

参考:
http://blog.csdn.net/zhaopenghhhhhh/article/details/38388159

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值