Search code examples
iosswiftuiimageicloudcloudkit

Uploading image to icloud using cloud kit throws error ios


I am facing one issue. Error is thrown when image is uploaded to icloud using cloud kit. It throws following error:

(< CKError 0x7ffad06b6780: "Internal Error" (1/5000); "Couldn't create a PCS identity">)

When image is not uploaded with other data, then other data is successfully uploaded. Here I have provided code I used to set image for uploading.

var noteRecord: CKRecord!
if let url = imageURL {
  let imageAsset = CKAsset(fileURL: url)
  print("imageAsset \(imageAsset)")
  noteRecord.setObject(imageAsset, forKey: "noteImage")
}

Solution

  • This is a user-specific issue that occurs with the iCloud Keychain and iCloud Drive folders after a user enables iCloud Drive on one of their devices.

    Example log:

    Oct 17 00:38:17 hostname.local com.apple.iCloudHelper[1284] :
    PCSIdentityCollectionSetup: {type = mutable dict, count = 3, entries
    => 0 : {contents = "kPCSSetupUsername"} = {contents = "appleID"} 1 : {contents = "kPCSSetupDSID"} = {contents = "<>"} 2 : {contents =
    "kPCSSetupPassword"} = {contents = "<>"} } Oct 17 00:38:17
    hostname.local com.apple.iCloudHelper[1284] :
    __PCSAccountHasStingrayIdentities Oct 17 00:38:19 hostname.local com.apple.iCloudHelper[1284] : PCSHasStingrayIdentities: YES Oct 17
    00:38:21 hostname.local com.apple.iCloudHelper[1284] :
    PCSCopyStingrayIdentity: {length = 1845, capacity = 1845, bytes =
    0x628207313082072d0c0f67616d63616c ... ab42b25d58020101} (error:
    (null)) Oct 17 00:38:21 hostname.local com.apple.iCloudHelper[1284] :
    PCSIdentityCollectionSetup failed The operation couldn’t be completed.
    (OSStatus error -25244 - SecItem failed to delete on private identity)
    

    A combination of iCloud keychain sync on the user's current device (or any other shared device they just associated with their account) or changing the permissions/deleting and rebuilding the shared iCloud folders associated with this user's keychain/account should solve this issue.

    Related discussion:

    Apple Stack Exchange - Setting up iCloud results in cloudd error messages

    Apple Support Communities - after upgrading to Yosemite iMac reboots random reboots randomly