Я создал кнопку для запроса моей базы данных Firestore. Я просто скопировал и вставил код из документации.
Код: Выделить всё
import UIKit
import Firebase
import FirebaseCore
import FirebaseFirestore
@objc func readButtonTapped() async {
let docRef = self.database.collection("TestCollection").document("TestDocument")
do {
let document = try await docRef.getDocument()
if document.exists {
let dataDescription = document.data().map(String.init(describing:)) ?? "nil"
print("Document data: \(dataDescription)")
} else {
print("Document does not exist")
}
} catch {
print("Error getting document: \(error)")
}
print("test read done")
}
Поток 1: EXC_BAD_ACCESS (код=1, адрес =0x8)
Проект запустился, и функция записи сработала. Делегат приложения настроен правильно. Нажатие кнопки приводит к появлению вышеуказанного сообщения об ошибке в делегате приложения.
Мой делегат приложения см. ниже:
Код: Выделить всё
import UIKit
import FirebaseCore
import FirebaseFirestore
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
let db = Firestore.firestore()
return true
}
Источник: https://stackoverflow.com/questions/781 ... lure-swift
Мобильная версия