FirebaseApp.configuration() unresolved identifier - ios

I'm creating a social app (out of personal interest) using Xcode on my macOS Catalina 10.15.6 and facing tons of config issues before really doing something.
I'm stuck in this swift compiler error for 2 days already: Use of unresolved identifier 'FirebaseApp'
I've updated Ruby successfully.
I followed the instructions on the firebase official website
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
}
I've met bumps all along after executing "pod init" in Terminal. This was solved after I updated Ruby. I've got some help from Stack Overflow posts but couldn't find the one that solve my problem.

I have found the official documentation regarding the setup misleading. Therefore I use import FirebaseCore when implementing FirebaseApp.configure() and not as suggested import Firebase.

Related

iOS Firestore App runs on Simulator but not on phone

I am developing an App that uses Firestore. The app runs fine on the Xcode simulator, but crashes when I try to run it on my phone. I get the following error message:
*** Terminating app due to uncaught exception 'FIRIllegalStateException', reason: 'Failed to get FirebaseApp
instance. Please call FirebaseApp.configure() before using Firestore'
I do call FirebaseApp.configure() in the didFinishLaunchingWithOptions:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
I don't understand why it would run in the simulator and not on my phone. Any help would be appreciated.
Check your podfile for how you add the firebase cocoapods, It should be like this,
pod 'FirebaseCore'
pod 'Firebase/Messaging'
If your podfile different ,please remove old firebase related pods,insert this and install.
I discovered, on a Japanese code forum, what to do. I added the following code to the AppDelegate.swift file:
var window: UIWindow?
override init() { //初期化メソッドを追記
FirebaseApp.configure()
}
The app now runs both in the simulator and on my iPhone.

Use of undeclared type 'GADUnifiedNativeAdLoaderDelegate'

I am trying to make a demo of this ads. While i follow this tutorial. Getting this error Use of undeclared type 'GADUnifiedNativeAdLoaderDelegate'. I am using the latest version of GoogleMobileAds.framework.
AppDelegate
import Firebase
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
// Initialize the Google Mobile Ads SDK.
GADMobileAds.configure(withApplicationID: "ca-app-pub-3940256099942544~1458002511")
return true
}
ViewController
import UIKit
import Firebase
import GoogleMobileAds
class ViewController: UIViewController, GADUnifiedNativeAdLoaderDelegate
I am using an older version(7.25.0) of Admob. The latest one is 7.29.0. When i have written pod 'Firebase/AdMob' in podfile at that time i got version 7.25.0. Then after i write pod 'Google-Mobile-Ads-SDK' so i got 7.29.0 version of AdMob.

NSException when using Firebase

I followed all the steps correctly to install Firebase to my iOS App and it still doesn't work. In the application method, I added FIRApp.configure() like so:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
And I keep receiving NSException errors. Firebase seems to work on my Android Project, what's the deal with iOS?
I believe this is some sort of Swift 3 issue, because I encountered a similar problem. After looking over the internet, I believe that Firebase 3 hasn't updated to recent Swift Syntax located in Swift 3. Many other developers are having trouble with it as well. As an alternative, you could switch back from Xcode 8 and into 7, which would allow you to create your application which will work with current IOS, and when Firebase updates, it will be easy for you to migrate to Swift 3.
Hope this helps,
Morgan Gallant

Swift 2.0 and Google Analytics: Use of unresolved identifier "GAI"

I tried with CocoaPods and wound up with this issue after trying for hours and figured it was CocoaPods. Uninstalled CocoaPods and installed the SDK manually and wound up with the same issue.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
GAI.sharedInstance().trackerWithTrackingId("UA-XXXX-Y");
return true
}
This results in the error Use of unresolved identifier "GAI". I have a bridging header that imports the appropriate header files and all the required libraries included in my Build Phases. Please help!
Apparently I just needed to clear my derived data and restart Xcode. Xcode sucks sometimes. Ha. Thank you Björn Ro.

App crashes ONLY when connected to XCode

My Swift app only seems to crash with EXC_BAD_ACCESS when my app is connected to XCode and I'm debugging. If I unplug my device and then run the app, it works flawlessly.
The app crashes at:
class AppDelegate: UIResponder, UIApplicationDelegate {
I'm pulling my hair out trying to solve this.
It's probably not a crash. More likely you have an Exception breakpoint and you're hitting it.
Try to replace your function with below one:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {}
or
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]!) -> Bool {}
That could be a pointer deallocating issue in the memory. That would be great if you can post more details about the error/crash info that you got, so that we can help you better. There are some solutions that you can try from this existing post, which was the similar problem(EXC_BAD_ACCESS) as you have: http://loufranco.com/blog/understanding-exc_bad_access
After a fiddling with the initial view controller I found that it only happened on the controller where my GMSMapView was. As it turns out, another user was having a similar problem here.
It turns out upgrading to iOS 8.4 solved the issue immediately. While I didn't use Dave's brilliant work around, I still give all the props and kudos to him!
Thank you everyone for sticking with me during this dark time in my life.

Resources