I\'m still pretty new to SwiftUI and Firebase. Recently, as a hobby, I have been developing an app for my school. After the launch of Xcode 12, I decided to experiment with
You can add the appDelegate
to your @main
SwiftUI view
First create your appdelegate on your widget extension
import Firebase
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
return true
}
}
look at @main, inside your widget extension,
@main
struct TestWidget: Widget {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
private let kind: String = "ExampleWidget"
public var body: some WidgetConfiguration {
...
}
}
@main
is new swift 5.3 feature that allows value type entry point, so this is will be your main entry point for your widget extension
just add @UIApplciationDelegateAdaptor
, inside your @main