合并 ios 静态库

Posted headchen随笔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了合并 ios 静态库相关的知识,希望对你有一定的参考价值。

合并 cordovaLib库:

 

lipo -create ‘Release-iphoneos/libCordova.a‘ "Release-iphonesimulator/libCordova.a" -output "libCordova.a"

 

查看: 

 

lipo -info libCordova.a

 

合并cordova脚本:

 

 

 define static library target name

LIB_NAME="Cordova"

 

# define output folder environment variable

UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal

DEVICE_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos

SIMULATOR_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator

 

# Step 1. Build Device and Simulator versions

# insert such -arch i386 before BUILD_DIR assign arch

xcodebuild -target "${LIB_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"

xcodebuild -target "${LIB_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"

 

# Cleaning the oldest and make sure the output directory exists

if [ -d "${UNIVERSAL_OUTPUTFOLDER}" ]

then

rm -rf "${UNIVERSAL_OUTPUTFOLDER}"

fi

mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"

 

# Step 2. Create universal binary file using lipo

lipo -create "${DEVICE_DIR}/lib${LIB_NAME}.a" "${SIMULATOR_DIR}/lib${LIB_NAME}.a" -output "${UNIVERSAL_OUTPUTFOLDER}/lib${LIB_NAME}.a"

 

# Last touch. copy the header files. Just for convenience

cp -R "${DEVICE_DIR}/include" "${UNIVERSAL_OUTPUTFOLDER}/"

?

#open the universal dir

open "${UNIVERSAL_OUTPUTFOLDER}/"

 

#delete DEVICE and SIMULATOR build file

#rm -rf "${DEVICE_DIR}"

#rm -rf "${SIMULATOR_DIR}"

以上是关于合并 ios 静态库的主要内容,如果未能解决你的问题,请参考以下文章

iOS合并lib(.a)库的可用方法(可用于解决duplicate symbol静态库冲突)

iOS 动态库+静态库

iOS打包.a静态库步骤

iOS 静态库和动态库相关

iOS 静态库打包流程简化

iOS 静态库打包流程简化