Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CloudKit Syncing #50

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions GamebookEngine/Data/GameDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
3 changes: 3 additions & 0 deletions GamebookEngine/GamebookEngine.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.$(CFBundleIdentifier)</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudDocuments</string>
<string>CloudKit</string>
</array>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
Expand Down
4 changes: 4 additions & 0 deletions GamebookEngine/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<false/>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down