错误提示:
错误原因:
是由于framework 包含了x86_64, i386 架构,这个是苹果不允许的。
解决办法:剔除掉x86_64, i386这两个架构
1、通过终端来去除
(1)查看一下framework包含的架构
lipo -info XXXX.framework/XXXX
或者
cd XXXX.framework
lipo -info XXXX
会出来结果
Architectures in the fat file: XXXX.framework/Realm are: i386 x86_64 armv7 arm64
(2)剔除
lipo XXXX.framework/XXXX -thin armv7 -output XXXX_armv7
lipo XXXX.framework/XXXX -thin arm64 -output XXXX_arm64
lipo -create XXXX_armv7 XXXX_arm64 -output XXXX
将这个重新output出来的XXXX替换之前的XXXX.framework/XXXX就好了,重新打包和真机运行都没问题
2、工程中添加脚本来去除
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_EXECUTAB LE_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
因为不是全部的sdk 都需要,所以这样会报错,只需要替换脚本中的一句代码就行,替换成需要的框架
$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
替换成
"$APP_PATH" -name '[frameworkname].framework' -type d | while read -r