Crash on FIRApp.configure() method - ios

I added a firebase framework using cocoapods to existing Project but a crash occurs at the FIRApp.configure() method.
To figure out the problem, I create a new project and add a firebase Framework which is working.
I don't know what could be the Problem.

Make sure GoogleService-Info.plist is in your build target.

Related

Why does my Flutter app crash at startup on iOS?

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?
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
Just get a Mac. Trying to debug through Codemagic won't work.
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
For AdMob, be sure to add your application ID to the info.plist. https://pub.dev/packages/firebase_admob
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.
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)
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
use terminal to run the app.
run this command
flutter run --release
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>
most probably you've faced with next Flutter issue https://github.com/flutter/flutter/issues/54707
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 .
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)

Swift Crashlytics without cocoapods and fabric API Key not showing dashboard or any data

I have implemented firebase Crashlytics in my swift projects without cocoapods. I have done the following task so far. But still, not getting anything on the dashboard.
Created project in firebase console. Downloaded the plist file and added to project.
Added the firebase library all with Firebase.h header file. Then added the header with an Obj-c bridge header file from settings. Also fabric and Crashlytics library.
Added the run script.
In appdelegate, didFinishLaunchingWithOptions() , added these 3 lines.
FirebaseApp.configure()
Fabric.sharedSDK().debug = true
Fabric.with([Crashlytics.self])
In a viewcontroller, added the following line, run on the simulator, make a crash, relaunch the apps. So that I can expect it to upload on the dashboard. Nothing found in the log, just see firebase enabled. Crashlytics version ...
Crashlytics.sharedInstance().crash()
From project settings i set , Debug Inforation Format : DWARF with dSYM File
But I see nothing on the dashboard. I don't use any API key in my Plist, I just using the plist in my project. What could be my problem?
I think I know what the issue is. You're probably running in the Simulator with the debugger attached.
Crashlytics can’t capture crashes if your build attaches a debugger at launch.
Docs for forcing a crash: https://firebase.google.com/docs/crashlytics/force-a-crash
To fix this, go to your app in the Simulator w/o the debugger attached and reproduce your crash. You should see your crash in the Firebase console.

Analytics not recognized

Been following the Firebase setup guide. The setup process worked, but my project doesn't recognize the Analytics type:
Analytics.logEvent // use of unresolved identifier 'Analytics'
Xcode autocomplete shows AnalyticsConfiguration, but nothing else. As a sanity check, here's what I did to set up my project:
Use cocoapods to fetch Firebase/Core
Ensure I'm using the .xcworkspace file
Added the GoogleService-Info.plist for my project
In my app delegate, import Firebase and call FirebaseApp.configure()
Realized what the problem was. My project name was "Analytics", and it somehow influenced the visibility of the framework named "Analytics".

Can't find Firebase's PhoneAuthProvider class

I'm working on adding a phone authentication login to my app, but my xcode just can't find the PhoneAuthProvider class. I have included
import Firebase
import FirebaseAuth
and the right pods installed
pod ‘Firebase/Auth’
pod ‘Firebase/Database’
pod ‘Firebase/Core’
Any idea to why it's not available for me?
Apparently it was because my Firebase pods were outdated, after updating them to the newest version I was able to use the class.
To update your Firebase pods, go to terminal and type in
pod update Firebase/Auth
I'm gonna leave it here as I've found a few similar questions without any answers.
It's a problem in creation or config project or app. You need just need go:
project-> add another app
and redo all process that you can create app.
In my case that worked.
Note: don't create another project because Firebase only provide 3 project to create.
You need to go to Project> Clean Build Folder. Build the project. This fixes my problem.
In my case I had to close whole XCode and then open it again, and everything worked fine.

Could not configure Firebase InstanceID

hi I'm trying to include firebase in my app and followed the documentation, when I'm trying to do google sign in, Could not configure Firebase InstanceID error occurs .please advice how to overcome this error
There are two things to check (and hopefully, one will fix it for you):
Make sure your BundleIdentifier is exactly the same in your Firebase project as it is in your Xcode, i.e. com.[yourcompany].[yourappname]
Make sure you got the latest GoogleService-Info.plist file. Go to Firebase Console -> Settings -> Your Application - there will be a blue button to the right that lets you download new configuration file
That solved it for me.
Bug Details
As of version 3.13.0, there appears to be a bug in the Firebase/Core SDK.
I added a symbolic breakpoint at -[FIRInstanceID(FIRApp) configureInstanceIDWithOptions:app:] and stepped though the assembly.
It appears that FIRApp.configure() is ignoring the IS_GCM_ENABLED flag in the GoogleServices-Info.plist and tries to configure GCM regardless of the flag's state. In my case, because my project does not use GCM, the app would crash because there was no GCM_SENDER_ID in the plist.
Workaround
Add a dummy value (i.e. 123456789012) for GCM_SENDER_ID within the GoogleService-Info.plist file. This will allow the application to configure successfully.
You have to add your project which is created on
https://developers.google.com/mobile/add?platform=ios or fire base console into your Firebase dashboard.
Now you can download GoogleService-Info.plist from Firebase and import into your project.
I setup Firebase in code using FIROptions. In my case, I was missing gcmSenderID, fixing it then it works
Firebase DevRel here. This should be an error, unless you enabled gcm, you shouldn't go through instanceid setup. Filed internally.
For now, the workaround is manually changing "IS_GCM_ENABLED" to "NO" in your "GoogleService-Info.plist" file
I was getting this error as I didn't have my GoogleService-Info.plist in my Test folder as well. ( if you are using TDD)
As of the latest Firebase Core 3.16.0 - I seem to need to include it in my main project as well as copying a version into my Test Root.
This also happens when you shift your google SDK integration from one account to another and don't edit the API keys on application side.Make sure when you shift from one google account to another, you re-visit all the SDK guides again like FCM, Google Sign-in etc and make sure you are using new API keys (client_id, URI Scheme) in application.

Resources