'Mac M1 -- Error launching application on iPhone 12 Pro Max.(Flutter.h and AMSupportURLConnectionDelegate, AMSupportURLSession) issue

I am new to ios development with flutter. While trying to build the app on ios simulator and external device (iphone xr), I get the following error--

objc[50354]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1f3d2c188) and ?? (0x1184482b8). One of the two will be used. Which one is undefined.
    objc[50354]: Class AMSupportURLSession is implemented in both ?? (0x1f3d2c1d8) and ?? (0x118448308). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **

Xcode's output:
↳
    FirebaseAnalytics-framework-aginbutuetuehmfqavbftszulegx
    /Users/.../ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'cloud_firestore' not found
    @import cloud_firestore;
     ~~~~~~~^~~~~~~~~~~~~~~
    1 error generated.
    FirebaseAnalytics-framework-aginbutuetuehmfqavbftszulegx
    /Users/.../ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'cloud_firestore' not found
    @import cloud_firestore;
     ~~~~~~~^~~~~~~~~~~~~~~
    1 error generated.
    FirebaseAnalytics-framework-aginbutuetuehmfqavbftszulegx
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete

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

Along with this, I am getting error in XCode AppDelegate.swift where it says-- "Flutter.h not found"

I am stuck on this issue for 2 weeks now and have tried almost all the solutions available to the problem.

Please help!

Regards



Solution 1:[1]

Using an M1 Apple Silicon chip, you may face those compiling errors about the Class AMSupportURLConnectionDelegate or AMSupportURLSession Class being implemented twice:

My trick to remove this issue is to use rosetta and recreate some files in your Flutter project.

Here's what to do:

Be sure you have a correct apple profile in your XCode Proj. (for code signing)
Be sure that you are opening terminal using Rosetta and not with ARM/Native

Then, and only then, try to run this command:

flutter clean && rm ios/Podfile ios/Podfile.lock pubspec.lock && rm -rf ios/Pods ios/Runner.xcworkspace && flutter run

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BLKKKBVSIK