3

I have a Core data iOS app which uses Cloudkit using NSPersistentCloudkitContainer - iOS 13 onwards. I have tested it on an iPad and iPhone and the sync works well. I have now tried to add Cloudkit to a similar Mac app using the same Cloudkit container (still development). Again this works as regards syncing, but quite often adding/deleting entities on the iPad results in a crash on the Mac, as shown below:

**libxpc.dylib`___xpc_activity_dispatch_block_invoke.109.cold.3:

0x7fff70a14423 <+0>:  pushq  %rbp
0x7fff70a14424 <+1>:  movq   %rsp, %rbp
0x7fff70a14427 <+4>:  xorl   %edi, %edi
0x7fff70a14429 <+6>:  callq  0x7fff70a144d8            ; symbol stub for: _os_assert_log
0x7fff70a1442e <+11>: movq   %rax, %rdi
0x7fff70a14431 <+14>: callq  0x7fff70a144ea            ; symbol stub for: _os_crash

-> 0x7fff70a14436 <+19>: ud2 **

The call stack shows: Call Stack

I am using NSFetchedResultsControllerDelegate, with some debug in the didChange func. Sometimes I can see a problem before a crash such as it saying it is about to insert an object at row 6 when the table itself has only 4 rows. I don't always get such a message.

In the FetchedResultsControllerDelegate didChange, I put the debug in the .delete part of the switch. I have seen things like it trying to delete item 8 when there are only 7 in the table. I don't let it do this, but I end up not deleting the item I want. It looks like maybe the CloudKit change requests are coming in in the "wrong" order??

Please can someone suggest how I could go about debugging this? Thanks.

guinnessman
  • 433
  • 5
  • 15
  • This question appears related to this one -> https://stackoverflow.com/questions/58758353/exc-bad-instruction-from-com-apple-xpc-activity-com-apple-cloudkit-scheduler-com I have created a sample project and sent it as feedback to Apple – Joey Slomowitz Apr 28 '20 at 05:53

0 Answers0