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
还没有评论,来说两句吧...