Home > Software engineering >  Flutter App doesn't run on iOS Simulator, flutter build ios works
Flutter App doesn't run on iOS Simulator, flutter build ios works

Time:02-16

I am trying to run my flutter app, which uses firebase, in the iOS simulator on my Apple Silicon Mac, but it is not working. flutter run throws the following error, but flutter build ios works without error. Does anyone have a similar problem and can help me? I have already tried the following things (unfortunately without success):

https://github.com/FirebaseExtended/flutterfire/issues/1979#issuecomment-590173571

https://github.com/FirebaseExtended/flutterfire/issues/1944

Flutter on IOS: fatal error: module 'cloud_firestore' not found

https://bleepcoder.com/flutterfire/562990746/cloud-firestore-fatal-error-module-cloud-firestore-not-found

Here is my terminal output (for flutter run):

flutter run
Multiple devices found:
sdk gphone arm64 (mobile)  • emulator-5554                        • android-arm64 • Android 11 (API 30) (emulator)
iPhone 13 Pro Max (mobile) • ABCD • ios           • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
[1]: sdk gphone arm64 (emulator-5554)
[2]: iPhone 13 Pro Max (ABCD)
Please choose one (To quit, press "q/Q"): 2
Launching lib/main.dart on iPhone 13 Pro Max in debug mode...
Running pod install...                                              8,7s
Running Xcode build...                                                  
 └─Compiling, linking and signing...                      2.778ms
Xcode build done.                                           18,1s
Failed to build iOS app
Error output from Xcode build:
↳
    objc[10675]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x2023af678) and
    /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1042402c8). One of the two will be used. Which one is
    undefined.
    objc[10675]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x2023af6c8) and
    /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x104240318). One of the two will be used. Which one is
    undefined.
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/XXXX/Development/recipe_vault_fl/ios/Pods/AppAuth/Source/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m:148:42: warning: 'openURL:' is
    deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]
          [[UIApplication sharedApplication] openURL:_appStoreURL];
                                             ^~~~~~~
                                             openURL:options:completionHandler:
    In module 'UIKit' imported from /Users/XXXX/Development/recipe_vault_fl/ios/Pods/Target Support Files/AppAuth/AppAuth-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/UIKit.fram
    ework/Headers/UIApplication.h:124:1: note: 'openURL:' has been explicitly marked deprecated here
    - (BOOL)openURL:(NSURL*)url API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:", ios(2.0, 10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");
    ^
    /Users/XXXX/Development/recipe_vault_fl/ios/Pods/AppAuth/Source/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m:156:61: warning: 'openURL:' is
    deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]
      BOOL openedInBrowser = [[UIApplication sharedApplication] openURL:requestURL];
                                                                ^~~~~~~
                                                                openURL:options:completionHandler:
    In module 'UIKit' imported from /Users/XXXX/Development/recipe_vault_fl/ios/Pods/Target Support Files/AppAuth/AppAuth-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/UIKit.fram
    ework/Headers/UIApplication.h:124:1: note: 'openURL:' has been explicitly marked deprecated here
    - (BOOL)openURL:(NSURL*)url API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:", ios(2.0, 10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");
    ^
    2 warnings generated.
    /Users/XXXX/Development/recipe_vault_fl/ios/Pods/AppAuth/Source/AppAuth/iOS/OIDExternalUserAgentIOS.m:168:58: warning: 'openURL:' is deprecated: first
    deprecated in iOS 10.0 [-Wdeprecated-declarations]
        openedUserAgent = [[UIApplication sharedApplication] openURL:requestURL];
                                                             ^~~~~~~
                                                             openURL:options:completionHandler:
    In module 'UIKit' imported from /Users/XXXX/Development/recipe_vault_fl/ios/Pods/Target Support Files/AppAuth/AppAuth-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/UIKit.fram
    ework/Headers/UIApplication.h:124:1: note: 'openURL:' has been explicitly marked deprecated here
    - (BOOL)openURL:(NSURL*)url API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:", ios(2.0, 10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");
    ^
    1 warning generated.
    /Users/XXXX/Development/recipe_vault_fl/ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'cloud_firestore' not found
    @import cloud_firestore;
     ~~~~~~~^~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order

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

Here is my terminal output (for flutter build ios):

flutter build ios
Running "flutter pub get" in recipe_vault_fl...                  1.910ms
Building XX.XXXXXXXX.XXXXXXXXXXXXX for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: XXXXXXXXXX
Running pod install...                                             11,2s
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         9,1s
Xcode build done.                                           134,6s
Built /Users/XXXX/Development/recipe_vault_fl/build/ios/iphoneos/Runner.app.

CodePudding user response:

Try those steps;

cd ios

pod deintegrate

pod install

cd ..

flutter clean

flutter build ios

flutter run

If it's not work then share your ios/Runner/AppDelegate.swift file please

CodePudding user response:

Try running your Xcode first and make sure that it's up-to-date. Open the {flutter_project}/ios build on Xcode then try to run the iOS project on the Simulator from there.

If you're still having issues, you can run this command on your Terminal. This usually resolves issues running Flutter iOS builds on the simulator and should set the path for the active developer directory.

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
  • Related