项目上架,打包遇到[x86_64, i386]问题
截屏2022-07-08 10.55.57.png
这是三方的SDK里面在生成framework这个SDK里面包含了x86_64, i386 架构,当然这个AppStore是不允许的,所以会在上传的时候报错,解决办法就是要这个SDK剔除掉x86_64, i386这两个架构
方法一:
网上看的一种不保险的的方法是在程序里加一个脚本,剔除禁止的架构 我试了一下,我的不可以
主要操作流程如下
解决办法:TARGETS->Build Phases->点击加号选择New Run Script Phase->然后复制粘贴下面代码
image# Without further ado, here’s the script. Add a Run Script step to your build steps, put it after your step to embed frameworks, set it to use /bin/sh and enter the following script:
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
方法二:
由于该问题的产生原因是因为x86_64, i386是模拟器使用的,而打包上传appStore是不允许的,所以需要移除这个框架
我的项目里面因为有阿里语音识别SDK的原因,有nuisdk.framework包含了这个,所以需要到这个framework下移除,具体操作如下:
1、打开终端,进入你的framework的路径下(cd /Users/MAC/Desktop/MyProject/nuisdk.framework)
2、lipo -remove i386 nuisdk -o nuisdk && lipo -remove x86_64 nuisdk -o nuisdk
【若有其他库,在进入,移除一下就好】
3、重新打开项目,clean一下,Build一下,记住不要跑模拟器,然后打包,上传成功
网友评论