这里是UIKit/SwiftUI的新手,现在我正在开发一个带有SwiftUI生命周期的UIKit应用程序,我遇到了这个问题
Cannot find type 'NSPersistentCloudKitContainer' in scope守则是:
import UIKit
import Firebase
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
//nothing
}
lazy var persistentContainer: NSPersistentCloudKitContainer = { **Here is problem**
let container = NSPersistentCloudKitContainer(name: "app_Swiftui")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
func saveContext () {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
}每次我的构建都失败了,我得到了这个错误。有人能帮我吗?
https://stackoverflow.com/questions/68914428
复制相似问题