参考资料
Bitcode适配
配置 xcodebuild 命令打包支持Bitcode
iOS中动/静态库支持bitcode的问题
使用xcodebuild
打包,添加BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode"
最后打包脚本(真机)如下:
xcodebuild -target xxxTargetName ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos VALID_ARCHS='armv7 armv7s arm64' ARCHS='armv7 armv7s arm64' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode"
检测.a是否包含bitcode,
otool -arch armv7 -l xxxx.a | grep __bitcode | wc -l
执行后,会输出个数一个数字,如果不支持,会显示0
当前只检测armv7架构,其他架构也需要同样检测
.a包添加bitcode后,大小从40M变成110M了
- otool小脚本:
echo '请输入.a的SDK名称(不需要.a后缀,比如libSDK)'
read variable
libName=$variable
lipo -info "${libName}.a"
archs=`lipo -archs ${libName}.a`
for arch in ${archs}
do
echo "执行: otool -arch ${arch} -l "${libName}.a" | grep __bitcode | wc -l"
otool -arch ${arch} -l "${libName}.a" | grep __bitcode | wc -l
done
网友评论