SwiftData + CloudKit unified logs to debug syncing

I was following the instructions of TN3163: Understanding the synchronization of NSPersistentCloudKitContainer

to get a sysdiagnose from my machine (after installing the CloudKit profile for macOS)

Then, I found an error message that looked interesting in the log, but it looked like this

CoreData+CloudKit: -[NSCloudKitMirroringDelegate _exportFinishedWithResult:exporter:](1492): <private>: Export failed with error:
Error Domain=CKErrorDomain Code=2 UserInfo={ContainerID=<private>, NSDebugDescription=<private>, CKPartialErrors=<private>, RequestUUID=<private>, NSLocalizedDescription=<private>, CKErrorDescription=<private>, NSUnderlyingError=0x768ff1ca50 {Error Domain=CKInternalErrorDomain Code=1011 UserInfo={CKErrorDescription=<private>, NSLocalizedDescription=<private>, CKPartialErrors=<private>}}}

There is some problems mentioned in <private>.

Those logs where from subsystem = com.apple.coredata and category = CloudKit

Looking at the profile from Apple to debug this

i see the subsystem com.apple.coredata was not in there.

I could finally get the logs by adding to my Info.plist

<key>OSLogPreferences</key>
    <dict>
      <key>com.apple.coredata</key>
      <dict>
        <key>CloudKit</key>
        <dict>
          <key>Enable-Private-Data</key>
          <true/>
        </dict>
      </dict>
    </dict>

as explained in Recording Private Data in the System Log

Still, it surprises me this is a problem to begin with.

  • Should i report to Apple an incomplete debugging profile?
  • Is it safe to keep the OSLogPreferences on for coredata/cloudkit for my app?

Thanks for reporting the issue related to the profile. Do you have a feedback report yet? If not, would you mind to file one and share your report ID here? Thanks.

Regarding OSLogPreferences, I'd probably not leave the key in the production code, because that risks privacy leakage. As an example, the log NSPersistentCloudKitContainer generates may contain something like the CloudKit container ID and user info (ckuserid), which you probably don't want to leak.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

I added the report now FB25444484. Thanks!