LoginSignup
1
1

More than 1 year has passed since last update.

【SwiftUI×Firebase】AppDelegate.swiftがない!となった時の対処法

Last updated at Posted at 2022-08-28

結論

~App.swiftを、こう書きましょう。
①〜③の順番でプログラムを書いてみましょう。

~App.swift
import SwiftUI
import FirebaseCore   // ① : Firebaseのセッティング

struct FirebaseCloudMessagingPracticeApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate   // ③ : Firebaseのセッティング
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

// ② : Firebaseのセッティング
class AppDelegate: NSObject, UIApplicationDelegate {
  func application(_ application: UIApplication,
                   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    FirebaseApp.configure()

    return true
  }
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1