Posts

Post not yet marked as solved
2 Replies
391 Views
Afternoon all, I am starting out and want to store data in the App, some will be user specific and some general. So I have a new developer account which should have CloudKit permissions. I am just trying to make any of the most basic example applications work, but keep hitting issues. I create an App, select CloudKit and SwiftData. When I go into the signing and capabilities I select the Team which has the developer account. Then the CloudKit is selected as I clicked it when creating the project, but no Container is selected. I create a Container using the +, it names it iCloud.com.mydomain.AppName. However it is coloured in Red text. I press the refresh and then it turns into black text, the Push Notifications appear all populated for 1 second then all disappear. I have nothing under Push now, only a Trashcan button. The Container is now selected however. Is this an issue that the Push notifications items appeared then vanished? When I then try to run the app, using any of the many attempts I have had with simple code samples, it always fails to create the Container, usually with an error like this: error: Store failed to load. <NSPersistentStoreDescription: 0x600000c79ce0> (type: SQLite, url: file:///Users/cal/Library/Developer/CoreSimulator/Devices/6D2BA1B3-C7CA-499D-A280-AFF4C5E98180/data/Containers/Data/Application/B9CD5E35-08BD-44CC-A72D-EB170E3691C6/Library/Application%20Support/default.store) with error = Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={NSLocalizedFailureReason=CloudKit integration requires that all attributes be optional, or have a default value set. The following attributes are marked non-optional but do not have a default value: Item: name} with userInfo { NSLocalizedFailureReason = "CloudKit integration requires that all attributes be optional, or have a default value set. The following attributes are marked non-optional but do not have a default value:\nItem: name"; If I go into the CloudKit database view on Apple, I see the Container listed, albeit it is marked as not deployed to production. To try to remove my newbie issues I have used many web examples, the most recent of which was the "A Beginner’s Guide to SwiftData with a to-do app" from medium.com, which should just work really, snipped from Item.swift below but I have tried several other simple examples which all give the same issue: import Foundation import SwiftData @Model class Item: Identifiable { var name: String init(name: String){ self.name = name } } Any ideas really appreciated. Thank you
Posted
by Madcal.
Last updated
.