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.

Posts under wwdc21-10015 tag

25 Posts

Post

Replies

Boosts

Views

Activity

Provisioning issue with CoreDataCloudKitDemo
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.
3
0
1.6k
Oct ’21
Redirect stdout not working on iOS 15
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?
0
0
727
Sep ’21
Question about sharing data via Cloudkit and Core Data - Creating CKShare
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?
1
0
1.3k
Sep ’21
App crashing while using collection view
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 { // //}
1
0
2.1k
Sep ’21
Provisioning issue with CoreDataCloudKitDemo
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.
Replies
3
Boosts
0
Views
1.6k
Activity
Oct ’21
Redirect stdout not working on iOS 15
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?
Replies
0
Boosts
0
Views
727
Activity
Sep ’21
Question about sharing data via Cloudkit and Core Data - Creating CKShare
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?
Replies
1
Boosts
0
Views
1.3k
Activity
Sep ’21
App crashing while using collection view
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 { // //}
Replies
1
Boosts
0
Views
2.1k
Activity
Sep ’21
Are there and SwiftUI examples for Core Data/Cloudkit Sharing
In the WWDC2021 talk on building apps that share data through CloudKit and Core Data there seems to be a lack of examples that use SwiftUI. Is there any place o find such examples or even a tutorial?
Replies
2
Boosts
0
Views
1.2k
Activity
Aug ’21