I've followed the steps do use Firebase for the macOS app I am creating. I pasted:
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
return true
}
}
into my code, but it gives errors for the UIApplicationDelegate.
I assumed it was because I needed NS for a macOS app but when I did NSApplicationDelegate it gave the error "'LaunchOptionsKey' is not a member type of class 'AppKit.NSApplication'". How do I fix this?
CodePudding user response:
Being an app for macOS means you will not have any UI*
classes.
In macOS the app delegate is NSApplicationDelegate
. The signature for the applicationDidFinishLaunching
delegate method is func applicationDidFinishLaunching(_ notification: Notification)
.
So your code becomes something like this:
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
FirebaseApp.configure()
}
}
This is not actually an issue of making Firebase compatible with macOS. This is more an issue of using AppKit code instead of UIKit code. The Firebase code is irrelevant here.