I am trying to setup a database for my Firestore however I tried reinstalling the pods and many other things and I still cannot get it to work because it shows this error:
Type 'Firestore' has no member 'firebase'
I do not know why that is as the Firebase docs show that this should be correct. The messaging part work, it's just there just in case it is causing the error somehow, please help me to solve this.
Link to Firebase > Firestore docs
This is my pod file code:
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
and this is my AppDelegate code:
//
// 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
}
}