16

I'm trying to build a simple app using Flutter for iOS and Android, but the app crashes on startup when I try to run it on an iPhone (Android runs fine). I don't have a mac, so I'm using Codemagic to compile a release build and deploy to TestFlight, then installing on an iPhone from there. Apple only shows their crash logs in Xcode as far as I can tell (nothing in App Store Connect online?), and since I don't have a mac, I can't see those. Any thoughts as to what I might be running into, or what information I can gather to debug the problem?

Thanks!

Edit: I've been digging around some more and it looks like the crash is related to the Firebase dependencies. If I create the Flutter demo project (flutter create ), it runs fine on iOS. However if I then add Firebase packages to pubspec.yaml, and manually add GoogleServices-info.plist, the app crashes on startup. (I'm not adding any code that uses Firebase yet.) GoogleServices-info.plist is supposed to be added with Xcode, but since I don't have Xcode or a mac, that makes it tough. The second answer to this question gives a suggestion: Where to save GoogleService-Info.plist in Flutter without Xcode? I tried making those changes but got the same result. Anybody have any recommendations for adding Firebase without a mac?

watts
  • 371
  • 1
  • 2
  • 11

9 Answers9

20

Ok, so here's what happened. Originally the app crashed on iOS because there were issues with the GoogleServices-info.plist file (probably). There were no error messages, so I didn't know where to look. I finally just went back to the simple demo app and started layering things back in to isolate the issue. The demo app would build and run on iOS with no problems, but when I added the Firebase dependencies (as a group), it failed. I had added the GoogleServices-info.plist file manually (outside of Xcode) and adjusted the references in ios/Runner.xcodeproj/project.pbxproj using a text editor, but that didn't do the trick.

At this point I finally broke down and got a MacBook. Debugging on the Mac, I could now see that the app crashed in debug mode on the emulator as well as when in release mode on a device, but still no helpful error messages. I added the GoogleServices-info.plist file using Xcode, so at least that piece was correct, but the app still crashed immediately. Going through the documentation, I realized that when I made the sample app, I had forgotten to add the app ID in the info.plist file for AdMob. At this point it was just AdMob causing the crash, not the other Firebase dependencies. I added that back in and things ran fine. I wish I had looked at that a month ago. Ugh.

Thanks @Mikhail Tokharev and @season for taking a stab at such a vague question. I wish I had more detail to share initially, but I didn't know enough yet to know what could be going wrong.

TL;DR

  1. Just get a Mac. Trying to debug through Codemagic won't work.
  2. For Firebase, be sure you actually add your GoogleServices-info.plist file through Xcode. Trying to add it manually and hack the project.pbxproj file probably won't work (this a practical recommendation, I didn't prove this conclusively). https://firebase.google.com/docs/flutter/setup?platform=ios#add-config-file
  3. For AdMob, be sure to add your application ID to the info.plist. https://pub.dev/packages/firebase_admob
Westy92
  • 19,087
  • 4
  • 72
  • 54
watts
  • 371
  • 1
  • 2
  • 11
  • Please remove your 4th point, that is not an answer point. :P – surajs1n Jun 06 '20 at 17:51
  • Removed the `GoogleServices-info.plist` that I added previously using Android Studio, and added again using Xcode, and it launched well but now it does not display any content, just a white screen. – ASAD HAMEED Nov 11 '20 at 16:51
  • I am not using firebase functionality at all. But my app is crashing immediately after opening the app. Its approved from testflight. After downloading from testflight and upon opening, app is crashing. I am not able to find the root cause. Any suggestions ? – MaheshPeri19 May 04 '21 at 02:47
  • Lol, same for me. To clarify, it was about this piece of code missing: `ADMOB_APP_IDca-app-pub-key` – Michał Dobi Dobrzański May 31 '21 at 19:16
  • Just adding this link to further clarify Asad's point how you should add your GoogleServices-info.plist as this was my problem https://firebase.flutter.dev/docs/installation/ios/#installing-your-firebase-configuration-file – James Jun 26 '21 at 10:08
5

I've been facing this error since the last few days and I happen to solve it today. So, I would like to share it with anyone facing startup error after connecting their iOS app to firebase.

I had followed all the steps while setting up a new iOS app with firebase and this was what exactly caused the error, in my case. If you have placed import 'Firebase' and Firebase.configure() in your AppDelegate.swift, then remove it and run your app again. I removed those two lines and it worked fine. Test it with Cloud Firestore (just make a button write something to your cloud firestore) and make sure you add await Firebase.initializeApp(); as well when the button is pressed.

I did all of those steps and it worked fine with me.

P.S. I did it with android studio in a Mac.

CybeX
  • 2,060
  • 3
  • 48
  • 115
Ramin Udash
  • 61
  • 1
  • 2
3

For any newbies out there like me, make sure registering firebase is before GeneratedPluginRegistrant in your ios/Runner/AppDelegate.swift file.

// This works without crashes, FirebaseApp.configure() after GeneratedPluginRegistrant crashes
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
ikben
  • 4,246
  • 4
  • 21
  • 27
cs guy
  • 926
  • 2
  • 13
  • 33
1

i had the same issue and i have fixed it as i was new to ios deployment i forgot to add capabilities which indeed crashed my app in testflight ...so please be sure you have added required capabilities in signing and capability tab in xcode

season
  • 336
  • 3
  • 13
  • Ok, that is something I haven't done. What capabilities are required for Firebase? I'm just using the standard flutter demo app with Firebase dependencies added, so none of the capabilities look like they apply. – watts Jun 05 '20 at 17:43
  • yes, As i was using firebasemessaging package... you need to add push notification and background tasks with bottom last 3 options from add capabilities ...and follow same as https://pub.dev/packages/firebase_messaging – season Jun 07 '20 at 02:56
  • Ok, thanks for the heads up. I haven't used Firebase Messaging yet, but it's on my to-do list to check it out. I'll make sure to remember that. – watts Jun 12 '20 at 20:16
1

use terminal to run the app. run this command

flutter run --release

Bavly adel
  • 11
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 21 '22 at 10:12
1

For iOS: In our case this happened because of Facebook plugin update.

Previous version: flutter_facebook_auth: ^3.5.1

New Version: flutter_facebook_auth: ^4.3.3

We were missing FacebookClientToken in Info.plist file. So after adding that it worked.

<key>FacebookClientToken</key>
<string>$(FACEBOOK_CLIENT_TOKEN)</string>
xkxeeshankhan
  • 351
  • 4
  • 8
0

most probably you've faced with next Flutter issue https://github.com/flutter/flutter/issues/54707

Mikhail Tokarev
  • 2,843
  • 1
  • 14
  • 35
  • Hey, thanks for the suggestion! I tried compiling with the most recent build in both the beta branch (1.17.0-3.4.pre) and stable branch (1.17.0), but neither fixed the issue. When I run the app on an iPhone it still crashes immediately. Also it looks like this bug affects both Android and iOS? In my case only iOS is crashing. – watts May 11 '20 at 17:29
0

I had the same problem and solved it as below :

In the folder of flutter sdk, I did git pull then run the app again and it was solved .

0

If you using Google Firebase library in flutter app

Make sure use FirebaseApp.configure() before GeneratedPluginRegistrant.register(with: self) in AppDelegate.swift file.

FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
Bholendra Singh
  • 980
  • 7
  • 14