标签:
最近项目组在做一些第三方功能的集成,不止一次的遇到第三方库冲突的问题,需要将冲突部分进行手动移除.
一般第三方的.a支持不同平台,需要将各个平台的冲突的xxx.o删除,才能解决引入冲突问题.
写了一个简单的脚本,可以删除冲突xxx.o,并且重新生成.a
参数${1}为与工程冲突的第三方功能的.a名称
参数${2}为冲突的.o文件名称
#!/bin/sh DEVICE_ARCHS=("armv7" "armv7s" "arm64" "i386" "x86_64") extra_count=${#DEVICE_ARCHS[@]} for((i=0;i<extra_count;i++));do mkdir -p ${DEVICE_ARCHS[i]} done for((j=0;j<extra_count;j++));do echo ${DEVICE_ARCHS[j]} lipo ${1}.a -thin ${DEVICE_ARCHS[j]} -output ${DEVICE_ARCHS[j]}/${1}_${DEVICE_ARCHS[j]}.a cd ${DEVICE_ARCHS[j]} && ar xv ${1}_${DEVICE_ARCHS[j]}.a rm -rf ${DEVICE_ARCHS[j]}/${1}_${DEVICE_ARCHS[j]}.a rm ${2}.o cd .. && ar rcs ${DEVICE_ARCHS[j]}/${1}_${DEVICE_ARCHS[j]}.a ${DEVICE_ARCHS[j]}/*.o rm -rf ${DEVICE_ARCHS[j]}/*.o done rm ${1}.a string=‘‘ for((j=0;j<extra_count;j++));do string+=${DEVICE_ARCHS[j]}/${1}_${DEVICE_ARCHS[j]}.a‘ ‘ done lipo -create ${string} -output ${1}.a for((i=0;i<extra_count;i++));do rm -rf ${DEVICE_ARCHS[i]} done
样例:
sh ./xxx.sh libX xxx
执行完成后libX.a中的xxx.o会被移除
标签:
原文地址:http://www.cnblogs.com/lizilong/p/5191214.html