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

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

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

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应用程序目录中,ios/Runner.xcworkspace以Xcode打开。

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

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

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

5、在Runner目标的Build Settings> Other Linker FlagsOTHER_LDFLAGS)中添加$(inherited) -framework Flutter

完结。

猜你喜欢

转载自blog.csdn.net/wangyajuncsd/article/details/115334355