Flutter:现有应用程序无法在 ios 中运行

Posted

技术标签:

【中文标题】Flutter:现有应用程序无法在 ios 中运行【英文标题】:Flutter: The existing app doesn't run in ios 【发布时间】:2020-08-14 04:21:58 【问题描述】:

我开始在 ios 中调试这段代码,但告诉我这个错误 但是android中的代码运行没有错误

这是我的安装插件:

cupertino_icons: ^0.1.2
  flutter_swiper: ^1.1.6
  mvc_pattern: ^3.4.1
  global_configuration: ^1.3.0
  http: ^0.12.0+2
  intl: ^0.16.0
  html: ^0.14.0+2
  shared_preferences: ^0.5.6
  flutter_html: ^0.10.4
  flutter_svg: ^0.17.4
  location: ^2.3.5
  dynamic_theme: ^1.0.0
  flutter_inappbrowser: ^1.2.2
  url_launcher: ^5.4.1
  firebase_messaging: ^6.0.13
  firebase_analytics: ^5.0.11
  cached_network_image: 2.0.0-rc
  flutter_sidekick: ^0.1.3
  rflutter_alert: ^1.0.3
  geolocator: ^5.3.1
  google_maps_flutter: ^0.5.26
  flushbar: ^1.10.0
  sms_autofill: ^1.2.1
  timer_count_down: ^1.0.1
  # flutter_launcher_icons: "^0.7.3"

/Users/user/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappbrowser-1.2.2/ios/Classes/SwiftFlutterPlugin.swift:480:24: warning: result of call to 'parse(options:)' is unused
        webViewOptions.parse(options: options)
                       ^    ~~~~~~~~~~~~~~
/Users/user/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappbrowser-1.2.2/ios/Classes/SwiftFlutterPlugin.swift:485:94: warning: forced cast from 'InAppBrowserWebViewController??' to 'InAppBrowserWebViewController' only unwraps optionals; did you mean to use '!!'?
        let webViewController: InAppBrowserWebViewController = self.webViewControllers[uuid] as! InAppBrowserWebViewController
                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                            !!
/Users/user/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappbrowser-1.2.2/ios/Classes/SwiftFlutterPlugin.swift:503:47: error: cannot assign value of type 'Double' to type 'UIWindow.Level'
                self.tmpWindow?.windowLevel = 0.0
                                              ^~~
                                              UIWindow.Level(rawValue:  )
/Users/user/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappbrowser-1.2.2/ios/Classes/SwiftFlutterPlugin.swift:540:55: error: 'UIWindowLevel' has been renamed to 'UIWindow.Level'
                        self.tmpWindow?.windowLevel = UIWindowLevel(baseWindowLevel! + 1)
                                                      ^~~~~~~~~~~~~
                                                      UIWindow.Level
UIKit.UIWindowLevel:2:18: note: 'UIWindowLevel' was obsoleted in Swift 4.2
public typealias UIWindowLevel = UIWindow.Level
                 ^
/Users/user/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappbrowser-1.2.2/ios/Classes/SwiftFlutterPlugin.swift:562:59: error: cannot assign value of type 'Double' to type 'UIWindow.Level'
                            self.tmpWindow?.windowLevel = 0.0
                                                          ^~~
                                                          UIWindow.Level(rawValue:  )
/Users/user/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappbrowser-1.2.2/ios/Classes/SwiftFlutterPlugin.swift:680:16: warning: value 'webViewController' was defined but never used; consider replacing with boolean test
        if let webViewController = self.webViewControllers[uuid] 
           ~~^~~~~~~~~~~~~~~~~~
                                                                 != nil
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

无法为模拟器构建应用程序。 在 iPhone 11 上启动应用程序时出错。 退出(sigterm)

【问题讨论】:

这很可能是 Flutter 插件问题,可能是因为 Swift 代码过于老旧,与当前的 XCode 不兼容。最好编辑您的 pubspec.yaml 并使用此插件的最新版本:flutter_inappwebview: ^2.1.0+1 @tgram 谢谢先生的回复,但我没有在我的代码中安装这个插件 插件 flutter_inappbrowser 自 2.0.2 版起已重命名为 flutter_inappwebview。请使用新的以获得更好的支持。 是的,先生,这个问题谢谢你,但如果运行应用程序无法连接到我的服务器并得到另一个错误imgur.com/4caHkOH 【参考方案1】:

是的,您需要使用最新版本的依赖项。

【讨论】:

以上是关于Flutter:现有应用程序无法在 ios 中运行的主要内容,如果未能解决你的问题,请参考以下文章

iOS项目中集成Flutter的最新适配升级

iOS - 无法在真实设备 iPhone 11 中运行 Flutter 应用程序。iOS - 15.2,Xcode 13.2.1,它在模拟器中工作

Flutter 现有项目到 WebApp + Firebase (Firestore + Hosting)

Flutter_tts 无法在 iOS 上运行

无法将flutter现有项目更改为flutter web

将Flutter添加到现有应用——过程中遇到的问题