文章首发整理个人博客,转载参考注明来源陕西毅杰;
最近在用Flutter开发的模块,在提交上架的时候,遇到如下问题了:
原因:
这个Flutter编译的framework里面包含了x86_64, i386 [架构],在AppStore是不允许的,所有会在上传的时候报错,解决办法就是剔除掉x86_64, i386这两个架构;
解决
找了一下资料,发现都是在编译前,运行一段脚本,试了好多次,终于有一个版本是没问题,可以上传成功的,以下脚本可以直接复制使用;
-
脚本路径如下图:
-
脚本如下
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
以上end,有问题,欢迎留言讨论;
往期推荐:
☛兄dei,请我喝杯茶☚