如何不升级Flutter至3.13,用3.0.5在iOS17设备启动应用?
无需升级Flutter在iOS17设备启动应用的临时解决方案
针对Flutter 3.0.5 + Xcode 15.2在iOS17设备上的启动问题,这里提供几个无需升级Flutter版本的临时修复方案:
修改Info.plist配置
在iOS项目的Info.plist文件中添加以下配置,规避iOS17与旧版Flutter的启动逻辑冲突:<key>UIApplicationSupportsIndirectInputEvents</key> <false/>部分场景下,配合确保
NSAppTransportSecurity允许必要网络请求,能有效缓解启动崩溃问题。调整Xcode编译设置
打开iOS项目的Build Settings:- 找到
Dead Code Stripping,将其设置为YES - Debug模式下,将
Optimization Level设置为None [-O0]
这些调整可避免Xcode 15.2的编译优化触发旧版Flutter的兼容性bug。
- 找到
临时替换AppDelegate启动逻辑
若能修改iOS项目原生代码,可调整AppDelegate的启动逻辑,回退到iOS17之前的窗口初始化方式:
对于Objective-C:- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.flutterViewController = [[FlutterViewController alloc] initWithProject:nil nibName:nil bundle:nil]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.rootViewController = self.flutterViewController; [self.window makeKeyAndVisible]; return YES; }对于Swift:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let flutterViewController = FlutterViewController(project: nil, nibName: nil, bundle: nil) window = UIWindow(frame: UIScreen.main.bounds) window?.rootViewController = flutterViewController window?.makeKeyAndVisible() return true }注:这个修改会跳过iOS17的多场景启动逻辑,仅作为临时应急方案,后续升级Flutter后需改回默认逻辑。
内容的提问来源于stack exchange,提问作者david72
相关产品推荐
相关产品推荐

