CloudKit in WatchOS Simulator

I'm using the following code on WatchOS 3, in an attempt to store data on CloudKit directly from the WatchKit Extension's InterfaceController class:

let recordID = CKRecordID(recordName: Utility.convertToID(Date()))

let usersContainer = CKContainer.default()
usersContainer.accountStatus(completionHandler: { accountStatus, error in
     if accountStatus == CKAccountStatus.noAccount {
          // Always True
     }
})


Using the iOS 10 simulator and paired WatchOS 3 simulator, I am always returned with noAccount from the CKContainer.accountStatus() completion handler.

This does not happen on my physical device.


Am I forgetting something, or is this an issue others have encountered?

Replies

Are you logged into iCloud in the simulator? Use Settings->iCloud to check.

Yes, on the paired iPhone simulator I am logged into iCloud and have enabled iCloud drive. I don't see any iCloud settings on the watch simulator.

in the watch extension target's capabilities, are you using the same container as your iOS app? not the default container for the watch extension


edited to add: you're right, it's not working. And in the Watch app on the iPhone simulator, tapping Apple ID says it cannot connect, if you're already logged into iCloud on the iPhone simulator. Resetting the simulators, then trying to sign on via the Watch app just moves to the iPhone Settings, but the Watch still isn't connected 😟

this is in watchOS 3 beta release notes



CloudKit usage is blocked on watchOS Simulators. Running any test will throw a “Not Authenticated” error even though you are signed in via the paired iOS Simulator.

Workaround: Use CloudKit on paired devices with watchOS 3 and iOS 10.


I'm actually with this problem in watchOS 4 beta 6. Anyone more?