我的Flutter应用程序为什么无法在iPhone上运行?

3

我成功在模拟器上运行我的应用程序(iPhone 12,iOS 14.5),但是在实际的iPhone 11 Pro Max(iOS 14.7.1)上运行时,只遇到黑屏问题。下面是来自Xcode的输出:

2021-09-16 18:48:00.155232+0300 Runner[2396:1009680] Metal API Validation Enabled 
2021-09-16 18:48:00.244991+0300 Runner[2396:1009680] Could not load the "LaunchImage" image referenced from a nib in the bundle with identifier "xxx.yyy.zzz" 
2021-09-16 18:48:00.353909+0300 Runner[2396:1009946] [VERBOSE-2:shell.cc(93)] Dart Error: Can't load Kernel binary: Invalid kernel binary format version. 
2021-09-16 18:48:00.354015+0300 Runner[2396:1009946] [VERBOSE-2:dart_isolate.cc(170)] Could not prepare isolate. 
2021-09-16 18:48:00.354185+0300 Runner[2396:1009946] [VERBOSE-2:runtime_controller.cc(382)] Could not create root isolate. 
2021-09-16 18:48:00.354213+0300 Runner[2396:1009946] [VERBOSE-2:shell.cc(576)] Could not launch engine with configuration. 
2021-09-16 18:48:00.367242+0300 Runner[2396:1009960] flutter: Observatory listening on http://127.0.0.1:54273/PrvtvZOQ8Wc=/

Flutter Doctor:

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-x64, locale
    ru-BY)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      flutter config --android-sdk to update to that location.

[✓] Xcode - develop for iOS and macOS
[✗] Chrome - develop for the web (Cannot find Chrome executable at
    /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
[✓] Connected device (2 available)

Xcode 12.5.1


已更新

要解决这个问题,请先运行rm -rf ~/flutter/bin/cache命令以删除缓存文件。然后,通过终端而非IDE运行flutter run命令以使Flutter下载缺失的文件。现在应该可以正常工作了。


今天我也遇到了这个问题 - 只在真实的iOS设备上出现,其他平台没有。 - Daniel N.
1
@DanielN。请查看我的更新。 - engong
我老实说最终降级了我的Flutter版本 - 虽然感谢你的标签! - Daniel N.
天啊!这浪费了我将近两个工作日 - rm -rf ~/flutter/bin/cache 对我很有帮助,尤其是在我的控制台中出现了那么多其他错误的情况下 - 谢谢!!!它影响了我的个人和工作笔记本电脑,但共同点是我最近从Flutter 2.2.3升级到2.5.0,然后降级回到2.2.3。Android工作得很好,但iOS不行,尽管删除了所有缓存...除了这一个。 - Rhisiart
1个回答

1

我使用rm -rf ~/flutter/bin/cache命令删除缓存后问题得到了解决。这个问题似乎是由于Flutter安装不当引起的。在删除缓存后运行flutter pub get应该可以重新下载包并重建项目。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接