Xcode14运行Flutter3.22.0的折中方式
Overview
目前项目升级到3.22.0,项目也早早添加了隐私清单,这也就意味着项目运行/编译需要在Xcode15上进行。
但有的时候仍需要在家中排查问题,虽然家中有个pro和air,但有的时候老婆也需要用pro搞些设计。而且air目前已经无法升级到最新的系统,相应地到Xcode也无法升级到Xcode15。
所以也需要修改项目,让其在Xcode14上运行,便于后期忘记,在此记录。
移除隐私清单文件
首先需要在移除壳工程中的PrivacyInfo.xcprivacy。
不需要直接删除,需要在TARGETS->Build Phases->Copy Bundle Resources中将其移除。
关闭Impeller渲染引擎
如果不关闭在运行的时候会报以下错误:
1 | [FATAL:flutter/shell/platform/darwin/ios/ios_context.mm(29)] Check failed: backend != IOSRenderingBackend::kImpeller. Software rendering is incompatible with Impeller. Software rendering may have been automatically selected when running on a simulator in an environment that does not support Metal. Enabling GPU pass through in your environment may fix this. If that is not possible, then disable Impeller. |
原因是因为在Flutter3.22.0渲染引擎默认被自动选择为Impeller,而Xcode14渲染与Impeller渲染引擎不兼容。
为了解决这个问题,为了解决这个问题我们可以在运行Flutter项目中添加--no-enable-impeller参数来禁用Impeller。例如:
1 | flutter run --no-enable-impeller |
这样做将强制Flutter使用旧的Skia渲染引擎,而不是Impeller。
当前我们也可以在壳工程的info.plist文件中添加以下键值来告诉Flutter在构建时禁用Impeller。
1 | <key>FLTEnableImpeller</key> |
最后:这些代码修改不要提交到git上!!!