Я пытаюсь настроить базу данных для своего Firestore, однако я попытался переустановить модули и многое другое, и я все еще не могу заставить ее работать, потому что она показывает эту ошибку:
Type 'Firestore' has no member 'firebase'
Я не знаю, почему это так, поскольку документы Firebase показывают, что это должно быть правильно. Часть обмена сообщениями работает, она просто на тот случай, если она каким-то образом вызывает ошибку, пожалуйста, помогите мне решить эту проблему.
Ссылка на Firebase > Документы Firestore
Это мой код файла pod:
project 'Pocket Games.xcodeproj'
platform :ios, '10.0'
target 'Pocket Games' do
use_frameworks!
pod 'Google-Mobile-Ads-SDK'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Canvas'
end
и это мой код AppDelegate:
//
// AppDelegate.swift
import UIKit
import CoreData
import UserNotifications
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
let db = Firestore.firestore() // <- This is the line that doesn't work and comes up with "Type 'Firestore' has no member 'firebase'"
// Firebase cloud messanging
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound], completionHandler: {(success, error) in
if error == nil {
print("notifications successful")
if CoreData.shared.saveData(entity: "Notifications", entitySub: ["games_updates","new_apps_from_developer","new_games","updates"], content: ["true","true","true","false"]) {
print("Notification CoreData setup successful")
}
}
})
application.registerForRemoteNotifications()
NotificationCenter.default.addObserver(self, selector: #selector(self.refreshTocken(_:)), name: NSNotification.Name.InstanceIDTokenRefresh, object: nil)
//-----------------------------
return true
}
func applicationDidEnterBackground(_ application: UIApplication) {
Messaging.messaging().shouldEstablishDirectChannel = false
}
func applicationDidBecomeActive(_ application: UIApplication) {
FireBaseHandler()
}
func applicationWillTerminate(_ application: UIApplication) {
}
// MARK: - FireBase remote messanging
@objc func refreshTocken(_ notification: NSNotification) {
let refreshTocken = InstanceID.instanceID().token()
print("\n***\n\(String(describing: refreshTocken))\n***\n")
FireBaseHandler()
}
func FireBaseHandler() {
Messaging.messaging().shouldEstablishDirectChannel = true
}
}