Reputation: 11
I am currently following the steps to add Firebase to an iOS app on this link: https://console.firebase.google.com/u/1/project/fir-198a3/overview
I have been able to follow the steps successfully until reaching the part where I need to add the "initialization code". It states that I need to add the code below the main AppDelegate class. But in my .xcworkspace file (the one created after adding the Cocoapods using terminal) I don't see any of the code that I have on my original one.
My question is then: What should I do to add to connect Firebase when your app starts up?
import UIKit
import Firebase
content_copy
This is the code I am supposed to copy: (I am running the latest Xcode version)
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
content_copy
return true
}
}
Upvotes: 1
Views: 2034
Reputation: 173
React Native App File ./ios/../AppDelegate.mm
#import "AppDelegate.h"
#import <Firebase.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
// Other config ...
}
Upvotes: 0
Reputation: 36782
try this, to connect to Firebase when your app starts up:
import SwiftUI
import Firebase
@main
struct TestApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
return true
}
}
Upvotes: 0