升级Flutter提示Your Xcode project requires migration

今天在升级Flutter后在vscode运行报错:

Your Xcode project requires migration. See https://flutter.dev/docs/development/ios-project-migration for details.
Error launching application on iPhone 11 Pro.

在Xcode(v11.4.1)里运行倒是没有问题......

想到之前flutter升级时:

Your flutter checkout has local changes that would be erased by upgrading. If
you want to keep these changes, it is recommended that you stash them via "git
stash" or else commit the changes to a local branch. If it is okay to remove
local changes, then re-run this command with --force.

直接终端:flutter upgrade --force,而没有保存本地的修改......
也不知道是不是这个锅

于是,
根据Flutter官网https://flutter.dev/docs/development/ios-project-migration的说明,需要手动配置支持Xcode11.4。

  • 1.用Xcode打开项目(ios/Runner.xcworkspace ),在Flutter文件下删除App.framework 和 Flutter.framework的引用,如图:


    删除两个frameworkde 引用
  • 2.然后在 Runner target build settings Build Phases >Link Binary With LibrariesBuild Phases > Link Binary With Libraries中确认是否删除了:
    确认是否删除
  • 3.在 Runner target build settings 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
  • 4.在Runner target Build Settings > Other Linker Flags(OTHER_LDFLAGS) 添加
 $(inherited) -framework Flutter.

我的原来就是有的,如果没有把它添加进去:
Other Linker Flags配置

这样就把Xcode11.4的支持搞定了,验证一下:

在Xcode中运行项目没有问题:
Xcode运行

在vscode中运行没有问题:
vscode运行
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容