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

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

运行了一下flutter项目

flutter run

报错如下:

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

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

flutter clean

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

flutter clean
cd ios
pod update Firebase/Firestore

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

原文如下:

This error can occur due to multiple reasons.

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.

Secondly, try to change the iOS version from Xcode if not done already.

Thirdly, it can occur due to some changes in the pods. To fix this follow the following steps:

rm ios/Podfile

flutter pub get to get packages.

Remove Pods folder from the ios folder in the directory.

cd ios then pod install

flutter clean

Run the project. ( Press F5 if you are using VSCode )

I hope this solves your issue.

但是博主执行命令如下:

1、flutter pub get 

2、将Pods文件夹在ios文件夹下移除(Remove Pods folder from the ios folder in the directory.)

3、cd ios 

4、pod install

5、flutter clean

6、flutter 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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值