flutter,升级xcode,执行flutter build ios --release --no-codesign报错

如题,升级了xcode到12.4之后,执行flutter build ios --release --no-codesign命令报错,错误如下;
flutter,升级xcode,执行flutter build ios --release --no-codesign报错_第1张图片

有的同学可能会包报其他的错误:

Building for iOS, but the linked and embedded framework 'App.framework' was built for iOS Simulator.
或者

Building for iOS Simulator, but the linked and embedded framework 'App.framework' was built for iOS.
 

直接说解决方法:要在xcode中配置Thin Binary脚本。下面有步骤,也可以参考flutter cn官方文档https://flutter.cn/docs/development/ios-project-migration

 

步骤:

1、用xcode打开你执行的flutter中的ios项目;

flutter,升级xcode,执行flutter build ios --release --no-codesign报错_第2张图片

在Flutter应用程序目录中,ios/Runner.xcworkspace以Xcode打开。

2、在“导航器”窗格中,找到 Flutter组,然后删除App.framework 和Flutter.framework

flutter,升级xcode,执行flutter build ios --release --no-codesign报错_第3张图片

3、在Runner目标构建设置中,选择“ 构建阶段”>“使用库链接二进制文件”进行 确认App.frameworkFlutter.framework 并且不再存在。还要在“构建阶段”>“嵌入框架”中进行确认。

flutter,升级xcode,执行flutter build ios --release --no-codesign报错_第4张图片

4、如下更改Runner目标构建设置 Build Phases> Thin Binary脚本:

/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" thin

flutter,升级xcode,执行flutter build ios --release --no-codesign报错_第5张图片

5、在Runner目标的Build Settings> Other Linker FlagsOTHER_LDFLAGS)中添加

$(inherited) -framework Flutter

flutter,升级xcode,执行flutter build ios --release --no-codesign报错_第6张图片

 

=====================我是分割线======================================

如果是混合开发的朋友,在执行中间件中执行flutter build ios --release --no-codesign报错,则:

1、去掉脚本中带有的 flutter clean命令和 flutter packages get命令;

2、手动在Terminal中执行 flutter clean,再执行 flutter pug upgrade;

3、在打开的xcode中一定要注意要选择证书,如下:

flutter,升级xcode,执行flutter build ios --release --no-codesign报错_第7张图片

最后再执行flutter build ios --release --no-codesign命令发现没有错误,则可以执行对应的脚本命令。

 

完结。

 

你可能感兴趣的:(flutter)