および がAppDelegate
SwiftUIから削除されたので、たとえばおよび にSceneDelegate
あったFirebase 構成のコードはどこに置けばよいですか?SceneDelegate
AppDelegate
現在、次のコードが私の中にありますAppDelegate
:
このコードをどこに置けばいいでしょうか?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseConfiguration.shared.setLoggerLevel(.min)
FirebaseApp.configure()
return true
}
ベストアンサー1
SwiftUIライフサイクルの解決策はこちらです。Xcode 12b / iOS 14でテスト済み
import SwiftUI
import UIKit
// no changes in your AppDelegate class
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print(">> your code here !!")
return true
}
}
@main
struct Testing_SwiftUI2App: App {
// inject into SwiftUI life-cycle via adaptor !!!
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}