更新xcode11之后真机和模拟器运行正常,打包报错IPA processing failed ,进一步查看日志发现如下错误:
Assertion failed: Expected 4 archs in otool output:后面说的是你的某一个framework
(不出意外的话应该是某一个动态库打包的时候没有移除模拟器架构,如果是自己开发的SDK,请注意动态库打包上架都需要移除模拟器架构!!!)
如果你也有类似问题,请在finder中打开这个sdk的目录进行以下操作:
1, 终端cd到framework所在的目录
2 查看SDK的二进制文件支持的CPU架构,如果只显示armv7 arm64,那么就没问题,如果有模拟器的架构x86_64, i386那就是有问题
lipo -info XXX.framework/XXX
3, 移除支持x86_64,i386的二进制文件
lipo XXX.framework/XXX -remove x86_64 -remove i386 -output XXX
4,替换framwork内部二进制文件[记得备份]
mv XXX XXX.framework/XXX
5查看剥离后的二进制文件支持的CPU架构,如果显示armv7 arm64,就完成剥离,可上传AppStore
lipo -info XXX.framework/XXX
如果你觉得以上操作比较麻烦,每次模拟器调试和打包还要替换对应的SDK,那么以下方式将更加简便的解决你的问题:
buildPhases->New Run Script Phase添加以下内容
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
OK,去打包吧~