近期打包SDK时突然发现以前的打包脚本不管用了,真机包和模拟器包无法合成,在终端使用lipo -create
手动合成发现:
xxxSDK have the same architectures (arm64) and can't be in the same fat output file
原因:Xcode12模拟器默认添加了arm64架构,真机包和模拟器包都包含了arm64架构。
修改方法如下:
设置方法
另外附上打包脚本:
if [ "${ACTION}" = "build" ]
then
#要build的target名
target_Name=${PROJECT_NAME}
echo "target_Name=${target_Name}"
#build之后的文件夹路径
build_DIR=${SRCROOT}/build
echo "build_DIR=${build_DIR}"
#真机build生成的.framework文件路径
DEVICE_DIR_A=${build_DIR}/Release-iphoneos/${PROJECT_NAME}.framework
echo "DEVICE_DIR_A=${DEVICE_DIR_A}"
#模拟器build生成的.framework文件路径
SIMULATOR_DIR_A=${build_DIR}/Release-iphonesimulator/${PROJECT_NAME}.framework
echo "SIMULATOR_DIR_A=${SIMULATOR_DIR_A}"
#目标文件夹路径
INSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}
echo "INSTALL_DIR=${INSTALL_DIR}"
#目标.framework路径
INSTALL_DIR_A=${SRCROOT}/Products/${PROJECT_NAME}/${PROJECT_NAME}.framework
echo "INSTALL_DIR_A=${INSTALL_DIR_A}"
#判断build文件夹是否存在,存在则删除
if [ -d "${build_DIR}" ]
then
rm -rf "${build_DIR}"
fi
#判断目标文件夹是否存在,存在则删除该文件夹
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
#创建目标文件夹 -p会创建中间目录
mkdir -p "${INSTALL_DIR}"
#build之前clean一下
xcodebuild -target ${target_Name} clean
#模拟器build
xcodebuild -target ${target_Name} -configuration release -sdk iphonesimulator
#真机build
xcodebuild -target ${target_Name} -configuration release -sdk iphoneos
cp -R "${DEVICE_DIR_A}" "${INSTALL_DIR_A}"
#删除模拟器中arm64架构
#lipo "${SIMULATOR_DIR_A}/${PROJECT_NAME}" -remove arm64 -output "${SIMULATOR_DIR_A}/${PROJECT_NAME}"
#合成模拟器和真机.framework包
lipo -create "${DEVICE_DIR_A}/${PROJECT_NAME}" "${SIMULATOR_DIR_A}/${PROJECT_NAME}" -output "${INSTALL_DIR_A}/${PROJECT_NAME}"
#打开目标文件夹
open "${INSTALL_DIR}"
fi
脚本使用:
脚本使用
网友评论