在 iPhone 上启动 Flutter 应用程序时出现错误。

7

我无法在运行于virtual box的catalina上的VSCode中测试我的Flutter应用程序。

从VSCode启动应用程序后,我只得到了一行错误信息 Error launching application on Najam’s iPhone. 然后应用程序在设备上打开,但随后与VSCode断开连接。

Launching lib/main.dart on Najam’s iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: H5PHS46J86
Running pod install...                 277.5s
Running Xcode build...                                                  
 └─Compiling, linking and signing...   114.5s
Xcode build done.                      346.8s
Installing and launching...            59.8s
Error launching application on Najam’s iPhone.

我尝试过的方法

像这里https://github.com/flutter/flutter/issues/69632#issuecomment-803646337建议的那样,我尝试了下面的解决方案,但对我不起作用:

  • 在Podfile中设置platform到10.0(platform :ios, '10.0')
  • 组合使用flutter cleanpod cache clean --allpod install

我还尝试了这个解决方案https://stackoverflow.com/a/64661277/7290043。 但它也没有起作用。

  • flutter clean pod cache clean --all

  • rm -rf ios/Flutter/Flutter.framework

  • flutter pub get

  • pod install

  • flutter run

我该怎么办?

enter image description here

2个回答

1
启动时间非常长。你正在使用什么类型的机器?可能是由于VSCode调试超时导致的。尝试直接从Xcode运行,并且a)观察是否保持连接,b)观察是否报告了任何进一步的错误。

谢谢回复。是的,它在Xcode中运行良好。但问题是我无法使用Xcode正确地调试我的应用程序。在VSCode中,我使用调试控制台并使用“print”语句来找到问题的根源。但不幸的是,在VSCode中我遇到了上述错误。有没有办法在VSCode中运行应用程序?@agreensh - Faizan Kamal

-1

同样的问题,我已经解决了:

  1. 进入flutter/bin/cache,删除flutter_tools.snapshot和flutter_tools.stamp;
  2. 进入flutter/packages/flutter_tools/lib/src/ios/devices.dart,找到'await observatoryDiscovery.uri.timeout(const Duration(seconds: 60))'
  3. 将60改为240
  4. 运行flutter run
  5. 哇,成功了

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