前提・実現したいこと
プログラミング、swift初学者です。
上のページを元にアプリ内メッセージを実装したいのですが、いまいち書いてあることがよくわからかなったため質問させていただきたいです。
上記ページ内の「5.」において、「Firebase モジュールがまだインポートされていない場合は、UIApplicationDelegate の中でインポートします。」とありますが、これは『AppDelegate.swift』内の『UIApplicationDelegate』{}内に記述するという認識で合っていますでしょうか。
この前提で進めていったのですが、エラーと『Thread 1: signal SIGABRT』とブレークポイント?が出てしまい先に進めません。
発生している問題・エラーメッセージ
Declaration is only valid at file scope と Use of unresolved identifier 'FirebaseApp'
該当のソースコード
swift
1import UIKit 2import CoreData 3 4@UIApplicationMain 5class AppDelegate: UIResponder, UIApplicationDelegate { 6 7 import Firebase 8 9 var window: UIWindow? 10 var backgroundTaskID: UIBackgroundTaskIdentifier = 0 11 12 13 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 14 // Override point for customization after application launch. 15 FirebaseApp.configure() 16 return true 17 } 18 19 func applicationWillResignActive(_ application: UIApplication) { 20 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 21 // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 22 23 self.backgroundTaskID = application.beginBackgroundTask(){ 24 [weak self] in 25 application.endBackgroundTask((self?.backgroundTaskID)!) 26 self?.backgroundTaskID = UIBackgroundTaskInvalid 27 } 28 } 29 30 func applicationDidEnterBackground(_ application: UIApplication) { 31 // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 } 34 35 func applicationWillEnterForeground(_ application: UIApplication) { 36 // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 37 } 38 39 func applicationDidBecomeActive(_ application: UIApplication) { 40 // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 41 } 42 43 func applicationWillTerminate(_ application: UIApplication) { 44 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 } 46 47 48} 49 50
試したこと
実行(Thread 1: signal SIGABRTと出てしまう)
補足情報(FW/ツールのバージョンなど)
xcode
swift
macbookpro