Flutter iOS build fails randomly

I keep facing intermittent build failures for the ios build of my Flutter project. Android is working fine. Every few days this happens, and then I do a combination of deleting my Pods folder and Podfile.lock file, pod cache clean --all, and running pod install, and the errors magically go away. This time however, nothing seems to be working and I keep getting the errors.

I am completely stuck and would really appreciate any help from my fellow developers. Here is the log I get when trying to run on iOS simulator (the weird part is that the errors are always different on every build):

Launching lib/main_dev.dart on iPhone 11 Pro Max in debug mode…
Running pod install… 16.3s
Running Xcode build…
Xcode build done. 148.9s
Failed to build iOS app
Error output from Xcode build:

** BUILD FAILED **

Xcode’s output:

In file included from /Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/FluttertoastPlugin.m:2:
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/UIView+Toast.h:328:19: warning: empty paragraph passed to ‘@param’ command [-Wdocumentation] @param sharedStyle


/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/UIView+Toast.h:343:25: warning: empty paragraph passed to '@param' command [-Wdocumentation]
@param allowTapToDismiss
~~~~~~~~~~~~~~~~~~~~~~~^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/UIView+Toast.h:343:9: warning: parameter 'allowTapToDismiss' not found in the function declaration [-Wdocumentation]
@param allowTapToDismiss
       ^~~~~~~~~~~~~~~~~
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/UIView+Toast.h:343:9: note: did you mean 'tapToDismissEnabled'?
@param allowTapToDismiss
       ^~~~~~~~~~~~~~~~~
       tapToDismissEnabled
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/UIView+Toast.h:362:20: warning: empty paragraph passed to '@param' command [-Wdocumentation]
@param queueEnabled
~~~~~~~~~~~~~~~~~~^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/FluttertoastPlugin.m:19:23: warning: unused variable 'viewController' [-Wunused-variable]
   UIViewController *viewController =
                     ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/FluttertoastPlugin.m:70:21: warning: unused variable 'topPadding' [-Wunused-variable]
           CGFloat topPadding = window.safeAreaInsets.top;
                   ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/FluttertoastPlugin.m:71:21: warning: unused variable 'bottomPadding' [-Wunused-variable]
           CGFloat bottomPadding = window.safeAreaInsets.bottom;
                   ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/fluttertoast-4.0.1/ios/Classes/FluttertoastPlugin.m:48:19: warning: unused variable 'size' [-Wunused-variable]
       NSNumber *size = call.arguments[@"size"];
                 ^
8 warnings generated.
In file included from /Users/hmhm/.pub-cache/hosted/pub.dartlang.org/square_in_app_payments-1.3.0/ios/Classes/FSQIPApplePay.m:17:
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/square_in_app_payments-1.3.0/ios/Classes/FSQIPApplePay.h:23:53: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
- (void)initWithMethodChannel:(FlutterMethodChannel *)channel;
                                                   ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/square_in_app_payments-1.3.0/ios/Classes/FSQIPApplePay.h:23:53: note: insert '_Nullable' if the pointer may be null
- (void)initWithMethodChannel:(FlutterMethodChannel *)channel;
                                                   ^
                                                    _Nullable
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/square_in_app_payments-1.3.0/ios/Classes/FSQIPApplePay.h:23:53: note: insert '_Nonnull' if the pointer should never be null
- (void)initWithMethodChannel:(FlutterMethodChannel *)channel;
                                                   ^
                                                    _Nonnull
1 warning generated.
In file included from /Users/hmhm/.pub-cache/hosted/pub.dartlang.org/square_in_app_payments-1.3.0/ios/Classes/SquareInAppPaymentsFlutterPlugin.m:19:
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/square_in_app_payments-1.3.0/ios/Classes/FSQIPApplePay.h:23:53: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
- (void)initWithMethodChannel:(FlutterMethodChannel *)channel;
                                                   ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/square_in_app_payments-1.3.0/ios/Classes/FSQIPApplePay.h:23:53: note: insert '_Nullable' if the pointer may be null
- (void)initWithMethodChannel:(FlutterMethodChannel *)channel;
                                                   ^
                                                    _Nullable
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/square_in_app_payments-1.3.0/ios/Classes/FSQIPApplePay.h:23:53: note: insert '_Nonnull' if the pointer should never be null
- (void)initWithMethodChannel:(FlutterMethodChannel *)channel;
                                                   ^
                                                    _Nonnull
1 warning generated.
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.13/ios/Classes/FLTFirebaseMessagingPlugin.m:196:43: warning: 'FIRMessagingRemoteMessage' is deprecated: FCM direct channel is deprecated, please use APNs for downstream message handling. [-Wdeprecated-declarations]
- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
                                         ^
In module 'FirebaseMessaging' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Headers/Public/Firebase/Firebase.h:72:
/Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/Public/FIRMessaging.h:219:1: note: 'FIRMessagingRemoteMessage' has been explicitly marked deprecated here
__deprecated_msg(
^
In module 'UIKit' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/sys/cdefs.h:191:48: note: expanded from macro '__deprecated_msg'
       #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                     ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.13/ios/Classes/FLTFirebaseMessagingPlugin.m:308:24: warning: 'FIRMessagingRemoteMessage' is deprecated: FCM direct channel is deprecated, please use APNs for downstream message handling. [-Wdeprecated-declarations]
   didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage {
                      ^
In module 'FirebaseMessaging' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Headers/Public/Firebase/Firebase.h:72:
/Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/Public/FIRMessaging.h:219:1: note: 'FIRMessagingRemoteMessage' has been explicitly marked deprecated here
__deprecated_msg(
^
In module 'UIKit' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/sys/cdefs.h:191:48: note: expanded from macro '__deprecated_msg'
       #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                     ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.13/ios/Classes/FLTFirebaseMessagingPlugin.m:142:30: warning: 'shouldEstablishDirectChannel' is deprecated: FCM direct channel is deprecated, please use APNs channel for downstream message delivery. [-Wdeprecated-declarations]
   [FIRMessaging messaging].shouldEstablishDirectChannel = true;
                            ^
In module 'FirebaseMessaging' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Headers/Public/Firebase/Firebase.h:72:
/Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/Public/FIRMessaging.h:283:56: note: 'shouldEstablishDirectChannel' has been explicitly marked deprecated here
@property(nonatomic) BOOL shouldEstablishDirectChannel DEPRECATED_MSG_ATTRIBUTE(
                                                      ^
In module 'UIKit' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/AvailabilityMacros.h:182:64: note: expanded from macro 'DEPRECATED_MSG_ATTRIBUTE'
           #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
                                                              ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.13/ios/Classes/FLTFirebaseMessagingPlugin.m:197:52: warning: 'appData' is deprecated [-Wdeprecated-declarations]
 [self didReceiveRemoteNotification:remoteMessage.appData];
                                                  ^
In module 'FirebaseMessaging' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Headers/Public/Firebase/Firebase.h:72:
/Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/Public/FIRMessaging.h:226:62: note: 'appData' has been explicitly marked deprecated here
@property(nonatomic, readonly, strong) NSDictionary *appData DEPRECATED_ATTRIBUTE;
                                                            ^
In module 'UIKit' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/AvailabilityMacros.h:180:60: note: expanded from macro 'DEPRECATED_ATTRIBUTE'
       #define DEPRECATED_ATTRIBUTE        __attribute__((deprecated))
                                                          ^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.13/ios/Classes/FLTFirebaseMessagingPlugin.m:307:1: warning: implementing deprecated method [-Wdeprecated-implementations]
- (void)messaging:(FIRMessaging *)messaging
^
In module 'FirebaseMessaging' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Headers/Public/Firebase/Firebase.h:72:
/Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/Public/FIRMessaging.h:253:1: note: method 'messaging:didReceiveMessage:' declared here
- (void)messaging:(FIRMessaging *)messaging
^
/Users/hmhm/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.13/ios/Classes/FLTFirebaseMessagingPlugin.m:309:63: warning: 'appData' is deprecated [-Wdeprecated-declarations]
 [_channel invokeMethod:@"onMessage" arguments:remoteMessage.appData];
                                                             ^
In module 'FirebaseMessaging' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Headers/Public/Firebase/Firebase.h:72:
/Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/Public/FIRMessaging.h:226:62: note: 'appData' has been explicitly marked deprecated here
@property(nonatomic, readonly, strong) NSDictionary *appData DEPRECATED_ATTRIBUTE;
                                                            ^
In module 'UIKit' imported from /Users/hmhm/AndroidStudioProjects/myProject/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/AvailabilityMacros.h:180:60: note: expanded from macro 'DEPRECATED_ATTRIBUTE'
       #define DEPRECATED_ATTRIBUTE        __attribute__((deprecated))
                                                          ^
6 warnings generated.
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===

Compiler message:
Error: Error when reading 'lib/main.dart': No such file or directory
package:myProject/main.dart: Error: No 'main' method found.
Try adding a method named 'main' to your program.
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.

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

Source: Ios