You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何不升级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:

    1. 找到Dead Code Stripping,将其设置为YES
    2. 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 11:27:07