解决日期:2019-7.31
环境
- Flutter: 1.7.8
- 使用VSCode编写Flutter模块
- Flutter模块导入方式参考:Google官方的Add Flutter to existing apps
flutter模块的Flutter.framework多了一个x86_64架构,苹果不予许多余加架构信息,所以要移除掉。
方法一:删除对应Flutter.framework的x86_64架构
- cd 到/path/xxx.framework位置
- lipo -info /path/xxx.framework/xxx 查看框架支持的架构
- 如:lipo -info Users/pppppp/oooooo/path/xxx.framework/xxx
- 删除Flutter模块x86_64:lipo -remove x86_64 xxx -o xxx
-
如:lipo -remove x86_64 Flutter -o Flutter
-
最后虽然移除了,但当我再次编译或运行或打包的时候,在次出现了类似的问题,看来木有完全解决掉。
方法二,脚本移除,但我不成功
类似,检查和IPA /存档删除不支持的架构[x86_64的,I386]
参考链接:http://cn.voidcc.com/question/p-nnevpoaf-x.html
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
方法三:最简单粗暴,一行代码成功,貌似在flutter官方有
-
在最后run script中,添加"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" thin
之前做flutter与原生混编时候Run Script有了前两行,故添加在最后一行。
兜兜转转问题解决了,之前一直有Google搜索,很多答案都是前两种,英文的相关很多,后面去百度搜索,相信很多人遇到过,国内的一些文章应该也会有,后来发现这最简单的。可能先去flutter相关issue找还更快,解决问题思路很重要,即使你是搜索查找答案。