From 742542f168e63b9a1b295210706eb20744c28ee6 Mon Sep 17 00:00:00 2001 From: Brad Root Date: Mon, 10 Apr 2023 23:07:09 -0700 Subject: [PATCH] first steps of trying to get cloudkit syncing to work --- GamebookEngine/Data/GameDatabase.swift | 16 ++++++++++++++-- GamebookEngine/GamebookEngine.entitlements | 3 +++ GamebookEngine/Info.plist | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/GamebookEngine/Data/GameDatabase.swift b/GamebookEngine/Data/GameDatabase.swift index c5c5fc9..6111a8d 100644 --- a/GamebookEngine/Data/GameDatabase.swift +++ b/GamebookEngine/Data/GameDatabase.swift @@ -14,11 +14,23 @@ class GameDatabase { static let standard: GameDatabase = .init() var mainManagedObjectContext: NSManagedObjectContext - var persistentContainer: NSPersistentContainer + var persistentContainer: NSPersistentCloudKitContainer init() { persistentContainer = { - let container = NSPersistentContainer(name: "BRGamebookEngine") + let container = NSPersistentCloudKitContainer(name: "BRGamebookEngine") + + // Only initialize the schema when building the app with the + // Debug build configuration. + #if DEBUG + do { + // Use the container to initialize the development schema. + try container.initializeCloudKitSchema(options: []) + } catch { + // Handle any errors. + } + #endif + container.loadPersistentStores(completionHandler: { _, error in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") diff --git a/GamebookEngine/GamebookEngine.entitlements b/GamebookEngine/GamebookEngine.entitlements index 367dc1b..c3c3386 100644 --- a/GamebookEngine/GamebookEngine.entitlements +++ b/GamebookEngine/GamebookEngine.entitlements @@ -2,6 +2,8 @@ + aps-environment + development com.apple.developer.icloud-container-identifiers iCloud.$(CFBundleIdentifier) @@ -9,6 +11,7 @@ com.apple.developer.icloud-services CloudDocuments + CloudKit com.apple.developer.ubiquity-container-identifiers diff --git a/GamebookEngine/Info.plist b/GamebookEngine/Info.plist index 23419e1..ed57460 100644 --- a/GamebookEngine/Info.plist +++ b/GamebookEngine/Info.plist @@ -50,6 +50,10 @@ LSSupportsOpeningDocumentsInPlace + UIBackgroundModes + + remote-notification + UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities