Build apps that share data through CloudKit and Core Data

RSS for tag

Discuss the WWDC21 session Build apps that share data through CloudKit and Core Data.

View Session

Posts under wwdc21-10015 tag

29 Posts
Sort by:
Post not yet marked as solved
5 Replies
1.1k Views
G'day everyone, I've had some problems with CoreData+CloudKit, and figured I would go back to basics and start from scratch with a new project. (Note: I'm using the Xcode 13.0 Beta with iOS 15 to try to use sharing on NSPersistentCloudKitContainer as discussed in WWDC2021, but these problems are scattered over the net without any answers to date) When I go through the motions of adding iCloud to the project, assign a new (unique) container and then build the app, two problems arise: the simulator comes back with a blank screen (without the Edit or add controls from the boilerplate). Even the preview pane seems broken (no "Add Item" button). This worked in Xcode 12, so I am assuming there is something that's come up as a bug here. More importantly, I get a swath of errors and warnings in the debug console related to CloudKit. It looks like there is some sort of identity problem here. There is no schema generated as yet in the CloudKit dashboard, so I am guessing that the migration errors are happening because the database hasn't yet established because of the identify problem. Does anyone have any insight into what I'm missing here? Thanks.
Posted
by
Post not yet marked as solved
3 Replies
807 Views
I've been struggling to get the CoreDataCloudKitDemo working. I've updated to Xcode 13 and followed the documented instructions closely. However, I'm getting this error: Provisioning profile "Mac Team Provisioning Profile: com.____.apple-samplecode.CoreDataCloudKitDemo" doesn't include the aps-environment entitlement. A bit of searching says this error is due to Push Notifications not being enabled. However, I do have them enabled. I cannot figure out why this won't run.
Posted
by
Post not yet marked as solved
2 Replies
719 Views
Hey all, I've just taken Xcode 13 Beta 2, and I still can't get the sample code from the "Sharing-Data" code to work properly, and nor does the boilerplate code from creating a new project that incorporates CodeData and CloudKit work. Fo far my feedback items have not been identified as having other similar issues - based on the posts I'm seeing I'm not the only one experiencing the same problem. Has anyone got this code built and working yet? Mine breaks when you try to copy the sharing link.
Posted
by
Post not yet marked as solved
0 Replies
468 Views
When I add a picture in a shared item from a device other than the owner I am getting an error in the console as follows: CoreData: Unable to provide a default CKRecordZoneID for database scope: Shared. Please note that I am using the sample project from the WWDC video titled Build apps that share data through CloudKit and Core Data. How might I be able to fix this error and what might be causing it?
Posted
by
Post not yet marked as solved
0 Replies
544 Views
We will soon be launching a gambling/gaming beta test in Virginia that will be IOS friendly. Although we do not yet have a license, we wont be integrating real money in the beta test. The currency in the beta test will only be play money that we will be using to prove the concept of our platform. Subsequently when that concept is proven, we will then get a license to incorporate real money and have third party payment processors. Judging from this synopsis, will we have any trouble getting approved by the apple app store?
Posted
by
Post marked as solved
1 Replies
788 Views
I was trying to have a secondary collection view with circle images above (y axis) the functioning collection view but its crashing and throwing this error Error code: could not dequeue a view of kind: UICollectionElementKindCell with identifier CircleCollectionViewCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard ViewController code: // //  ViewController.swift //  Main_app // //  Created by Kushagr Agarwal on 23/08/21. // import UIKit class ViewController: UIViewController {     @IBOutlet var collectionView: UICollectionView!          @IBOutlet var topCollectionView: UICollectionView!          @IBOutlet weak var Leading: NSLayoutConstraint!          @IBOutlet weak var Trailing: NSLayoutConstraint!          @IBOutlet private weak var Menubutton: UIButton!     var menuOut = false               override func viewDidLoad() {         super.viewDidLoad()         // Do any additional setup after loading the view.         //self.navigationItem.titleView = UIImageView(image: UIImage(named: "Logo"))                  collectionView.register(MiddleCollectionViewCell.nib(), forCellWithReuseIdentifier: MiddleCollectionViewCell.identifier)                  collectionView.delegate=self         collectionView.dataSource=self                  topCollectionView.register(CircleCollectionViewCell.self, forCellWithReuseIdentifier: CircleCollectionViewCell.identifier)         topCollectionView.delegate=self         topCollectionView.dataSource=self //       Menu //       start                  let destructiveAction = UIAction(title: "Delete",image: UIImage(systemName: "nosign") , attributes: .destructive) { (_) in             print("Delete")         }                  let menu = UIMenu(title: "", children: [             UIAction (title: "Add New", image: UIImage(systemName: "plus.circle"), handler: { _ in  }),             UIAction (title: "Manage", image: UIImage(systemName: "hammer"), handler: { _ in  }),             destructiveAction         ])         self.Menubutton.menu = menu //    Menu end     } // Menu animation     @IBAction func MenuTap(_ sender: Any) {         if menuOut == false {             Leading.constant = -150             Trailing.constant = 150             menuOut = true         }         else{             Leading.constant = 0             Trailing.constant = 0             menuOut = false         }         UIView.animate(withDuration: 0.2, delay: 0.0 , options: .curveEaseIn,animations: {             self.view.layoutIfNeeded()         }){(animationComplete) in             print("Animation Completed")         }     } // Menu animation ends } // used for upper collection view extension ViewController: UICollectionViewDelegate {          func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {         collectionView.deselectItem(at: indexPath, animated: true )         print("btn tapped")              }           } extension ViewController: UICollectionViewDataSource {     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {         return 12     }     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MiddleCollectionViewCell.identifier, for: indexPath) as! MiddleCollectionViewCell         let topcell = collectionView.dequeueReusableCell(withReuseIdentifier: CircleCollectionViewCell.identifier, for: indexPath) as! CircleCollectionViewCell         topcell.configure(with: "")                  cell.configure(with: UIImage(named: "four")!)         return cell; topcell     } } //extension ViewController: UICollectionViewDelegateFlowLayout { // //}
Posted
by
Post not yet marked as solved
1 Replies
531 Views
I am trying to use the new API provided by WWDC21 to create Core Data databases that can be shared. When I do the sharing for an NSManageObject, I tried to experiment with 2 methods. 1: Using UICloudSharingController's UICloudSharingController(preparationHandler: (UICloudSharingController, @escaping (CKShare?, CKContainer?, Error?) -> Void) -> Void) method. Currently this method works and the participants can get all the data after accepting the invitation. 2:Use NSPersistentContainer's share(_ managedObjects: [NSManagedObject], to share: CKShare?) async throws -> (Set<NSManagedObjectID>, CKShare, CKContainer) method. First get ckshare, then call UICloudSharingController(share:, container: ) With this approach, after accepting the invitation, the participant only gets the data generated after the creation of the ckshare, and the data before the ckshare is never fetched I'm not sure if it's an error in the token generated by the share method of the NSPersistentContainer or something else. Has anyone encountered a similar situation?
Posted
by
Post not yet marked as solved
8 Replies
2.2k Views
I have been excited to add NSPersistentCloudKitContainer's share functionality to my app but I've noted a few thing I suspect are bugs: -When using share() on a NSManagedObject the share record is set up in a new zone. However, the root NSManagedObject's record is not being updated with the relationship linkage to the shared record. -Secondly, when you revoke a share, the cloudkit.share record is removed from iCloud, but not in the local data stores. This makes the fetchShares() method ineffective for detecting a missing cloudkit.share record. In order to re-share the root object the developer must call out to iCloud directly using the old methods to be sure if the share exists or not. I am using the code from Apple's 'Synchronizing a Local Store to the Cloud' sample. It would be nice if they added support for revoking shares into this sample and addressed these issues.
Posted
by
Post not yet marked as solved
0 Replies
343 Views
I create a tool XLLoger, that can redirect stdout to the textView, It works well on iOS14 and below, but on iOS15, when the app running on Xcode connecting the device or simulator, the code can get the logs, if disconnected xcode, the app can't get print log, the NSLog can be get. I changed a variety of methods to redirect logs, all of which are the same phenomenon. Anything wrong with my code?
Posted
by
Post not yet marked as solved
0 Replies
340 Views
I have an app for client management that stores data in Core Data with an NSPersistentCloudKitContainer. Each manager have their clients in the Core Data Private Database, and each client could have associated files (images, documents, etc) that are stored in app's own folder structure in iCloud Drive. Eventually, a manager can decide if to share a client with another manager, in order to have a shared managed client (readable, or writable+readable by others managers which share the same client). This is done by moving the Client from the Private Database to the Shared Database following the Apple's guidelines: https://developer.apple.com/videos/play/wwdc2021/10015/ This is the structure: The problem is: the database record is shared correctly, but the iCloud Drive Files are not shared (obviously). My goal is to get working the iCloud Drive Client Files (every client has a single Folder) with the minimum effort from the user. I cannot get working the iCloud Drive Sharing from my app, only the Core Data Sharing, so (in development environment) I have to share the Client Core Data Info from the App sheet, and then, go to Finder and share the Client's folder and send the link, so it would be a bit confusing for my users. Any approach for get working iCloud Drive File Sharing from the (inside) my app? Generate a link and automatically send to the other user. Or, better, an approach to get working this sharing with a single action from the user (only share once, and it sends the core data info and icloud drive file sharing).
Posted
by
Post not yet marked as solved
0 Replies
335 Views
Hello everyone, in the App I'm building I'd like to share an entire list of items (records) by just sharing the list itself (parent record or RecordZone). Meanwhile, I'd like to continue using the NSPersistentCloudKitContainer and therefore CoreData sync. Is it possible, with the new features Apple introduced (Sharing RecordZone and Sharing in Cloud & Local Storage), to do what I described, and combine both functions. Thank you, Carlos Steiner
Posted
by
Post not yet marked as solved
0 Replies
375 Views
Now, when using NSPersistentCloudKitContainer.share(_ managedObjects: [NSManagedObject], to share: CKShare?), A deep traversal will be performed among the objects and any related objects will also be shared. For example, if there are 100 posts with the same tag, I shared one of them, and the remaining 99 will be shared at the same time. Is there any way to control whether the relationship should be shared?
Posted
by
Post not yet marked as solved
2 Replies
735 Views
Dear: Use core data to store super long strings. After storage, the strings are incomplete. Xcode tips: CoreData: debug: PostSaveMaintenance: fileSize 30409752 greater than prune threshold CoreData: annotation: PostSaveMaintenance: wal_checkpoint(TRUNCATE)  help me?
Posted
by
Post not yet marked as solved
0 Replies
306 Views
I am running the WWDC21 sample application "CoreDataCloudkitDemo" with two different Apple IDs to test the Cloudkit sharing feature. I use two simulators and one real device, where the latter has the same ID as one of the simulators. While creating invites via "Copy link" works on all three installations, accepting invites only works on the real device. Trying to open an invite (by copying the link in the one and pasting it into Safari in the other) always results in a web page stating that "iCloud has stopped responding" and "Unable to find applicationIdentifier for the containerId = [my ID] and fileExtension = undefined". Is this a simulator bug in Xcode 13.2 or is there anything I can do about it? Other iCloud features (including login via Safari to icloud.com) work in both simulators. Is there a way to open invite URLs in a simulator (as there is no functioning iMessage or Mail app) other than Safari's URL input field? Doing so does not work in the real device either, but clicking it in e.g. iMessage works. Edit: Pasting the link into a ToDo item and opening it from there works even in the simulator - so is it just a Safari issue?
Posted
by
LPG
Post not yet marked as solved
1 Replies
358 Views
I am trying to add CloudKit sharing to my app using the new iOS 15 share method https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer/3746834-share In the app there are 3 core data entities (Folder, Item, Comment) with the following relationships: A Folder contains many Items An Item has many Comments I want to use CloudKit to share just the Item entity, not any of its relationships. Is this possible to do with the share(_:to:completion:) method? Currently, when I pass an Item to the share method it also includes the Folder and Comments in the CKShare. How do I prevent this?
Posted
by