5 Replies
      Latest reply on Oct 18, 2016 10:56 PM by -jon-
      -jon- Level 1 Level 1 (0 points)

        When trying to get a record from our public store on the iOS 10 beta, we get the error: "Couldn't get a PCS object to unwrap encrypted data for field encryptedPublicSharingKey". The app was compiled with XCode 7.3 for iOS 9.3 target. But it does not use any deprecated methods for CloudKit on iOS 10 so it should work fine. And indeed it does work fine on our iPads with iOS 9.3.x internally.

         

        What's up with this error?

         

        Full text:

         

        <CKError 0x157487d0: "Internal Error" (1/5001); "Couldn't get a PCS object to unwrap encrypted data for field encryptedPublicSharingKey: (null)">

        • Re: CloudKit Error about PCS Objects?
          DaddieMac Level 1 Level 1 (0 points)

          Getting this error too. What is the deal?

          • Re: CloudKit Error about PCS Objects?
            -jon- Level 1 Level 1 (0 points)

            I requested a Code-Level Support incident for this on 9/15. Still waiting to hear back. I also posted on Stack Overflow, with a +50 bounty, and still not a single answer.

             

            This is really vexing.

             

            Here is my code:

             

            CKDatabase *publicDatabase = [[CKContainer defaultContainer] publicCloudDatabase]; 
            CKRecordID *myRecordID = [[CKRecordID alloc] initWithRecordName:@"myRecord"]; 
            [publicDatabase fetchRecordWithID:myRecordID completionHandler:^(CKRecord * _Nullable record, NSError * _Nullable error) { 
                if(error != nil) { 
                    NSLog(@"<ERROR> Error fetching record. Error: %@",error); 
                    return; 
                } 
                NSLog(@"Yay it worked.");
                // Code to do stuff
            

            }];

             

            I mean this code is basically copied straight out of Apple's own documentation. It works perfectly on iOS 9, built with XCode 8. Same build, on iOS 10, we get this error when trying to fetch the record:

             

            Error: <CKError 0x15e7c2b0: "Internal Error" (1/5001); "Couldn't get a PCS object to unwrap encrypted data for field encryptedPublicSharingKey: (null)">

            • Re: CloudKit Error about PCS Objects?
              amilham Level 1 Level 1 (10 points)

              I'm experiencing the same problem, only in iOS 10. It seems to happen only on records that have shortGUIDs. Not only can they not be fetched by record ID, but they aren't returned by queries either. I experimented by creating some test objects without short GUIDs that were fetched by the query with no problem, but then as soon as I added the short GUID (through the CloudKit dashboard), the objects were no longer fetchable in any way. The exact same data is fetchable and queryable with no problem on iOS 9.

               

              This happens for me in both the production environment and development environment.

               

              Anybody have any idea what's going on here?

                • Re: CloudKit Error about PCS Objects?
                  amilham Level 1 Level 1 (10 points)

                  This is still an issue. I can't set short GUIDs for sharing purposes, otherwise those items just won't show up in the app. In addition, I'm having another CloudKit failure for some users: https://forums.developer.apple.com/thread/64412

                  • Re: CloudKit Error about PCS Objects?
                    -jon- Level 1 Level 1 (0 points)

                    I can confirm it only happens when Short GUIDs are set. I wish I had seen your post a month ago! I forgot this thread was here.

                     

                    I suspect this is caused by the new CloudKit sharing features that have been enabled in iOS 10. The Short GUID's purpose is solely related to these sharing features. If you enable the Short GUID for a record, then CloudKit expects you're going to want to share this record, hence why it looks for the encryptedPublicSharingKey. However, if you have no sharing zones, you probably also don't have an encryptedPublicSharingKey (I'm guessing). I am also guessing sharing relies on push notifications to some degree, so if you don't have that set up properly, then you also might be missing that key. (Just guessing though).

                     

                    I note that maybe it's because it's in the Default zone, because the Default zone does not have sharing enabled, but yet it still lets you set the Short GUID. Why would something that's not shareable be able to have a Short GUID, which is only used for sharing?

                     

                    "Sharing is only supported in zones with the CKRecordZoneCapabilitySharing capability. The default zone does not support sharing." (CKRecord.h, l. 204)

                     

                    I note that the bug doesn't happen with records created in custom zones in the private DB.

                     

                    Anyway I have filed a bug report with Apple and also put in a tech support request. Apple confirmed to me on Friday that the bug is with the CloudKit server. The Apple dev tech support e-mail said:

                     

                    Just let you now that the CloudKit engineering confirmed that the issue is a bug on our server side. They are working on having that fixed now. I however don’t know when the fix will be done and deployed.

                     

                    I went ahead and updated the bug report to let them know it is related to the Short GUID. FYI my bug report number is

                    28572784