Flutter-flutter run报错Could not build the application for the simulator.

忘是亡心i 2023-10-04 15:21 152阅读 0赞

今天启动了一下flutter项目,执行

运行了一下flutter项目

  1. flutter run

报错如下:

  1. Could not build the application for the simulator.
  2. Error launching application on iPhone 12 Pro Max.

20210604155305227.png

最开始是直接先执行flutter clean 命令,然后再运行,发现还是报错

  1. flutter clean

仔细看了一下报错信息,发现是ios文件下Podfile中某个库没拉下来,导致找不到头文件,于是执行下面命令,还是不行

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01pbmdnZVFpbmdjaHVu_size_16_color_FFFFFF_t_70

  1. flutter clean
  2. cd ios
  3. pod update Firebase/Firestore

最后在Stack Overflow上找到一个答案,解决掉了

原文如下:

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01pbmdnZVFpbmdjaHVu_size_16_color_FFFFFF_t_70 1

  1. This error can occur due to multiple reasons.
  2. Firstly, it can occur due to some native error which can be found by building the app in Xcode using + B. If that's the case then you can solve the error and try building the app in the Xcode itself. If it succeeds in the building process then your app will run from Simulator.
  3. Secondly, try to change the iOS version from Xcode if not done already.
  4. Thirdly, it can occur due to some changes in the pods. To fix this follow the following steps:
  5. rm ios/Podfile
  6. flutter pub get to get packages.
  7. Remove Pods folder from the ios folder in the directory.
  8. cd ios then pod install
  9. flutter clean
  10. Run the project. ( Press F5 if you are using VSCode )
  11. I hope this solves your issue.

但是博主执行命令如下:

  1. 1flutter pub get
  2. 2、将Pods文件夹在ios文件夹下移除(Remove Pods folder from the ios folder in the directory.)
  3. 3cd ios
  4. 4pod install
  5. 5flutter clean
  6. 6flutter run

我并没有执行 rm ios/Podfile 命令,不然执行 pod install 命令时会导致报错:找不到Podfile文件

具体参考:

https://stackoverflow.com/questions/59188631/could-not-build-the-application-for-the-simulator-after-adding-cloud-firestore-t

https://stackoverflow.com/questions/64263716/could-not-build-application-for-the-simulator-for-flutter

发表评论

表情:
评论列表 (有 0 条评论,152人围观)

还没有评论,来说两句吧...

相关阅读