I found that the main application and widget NSUbiquitousKeyValueStore data is completely independent? (I signed in to the same iCloud account, the same AppGroup, the same iCloud Containers for the app and widget, and Key-value Storage was checked.)
But when I get on the widget and modify NSUbiquitousKeyValueStore data, find the Key to the value of the same, such as in the screenshot, the main application of 'gemstone' value is 24, But the widget's value is still 0.
I thought it was a synchronization problem, but using NSUbiquitousKeyValueStore.default.synchronize()
or restart the App didn't solve the problem
... “Add Image”function can't used, this is the Logs: Main App Logs: ---ubiquitousKeyValueStoreDidChange ---Change reason: 0 ---The key 'experience' was updated to value '-28' ---UbiquitousKeyValueStoreDidChange: [AnyHashable("NSUbiquitousKeyValueStoreChangedKeysKey"): <__NSSingleObjectArrayI 0x280098960>( experience ) , AnyHashable("NSUbiquitousKeyValueStoreChangeReasonKey"): 0] ---ubiquitousKeyValueStoreDidChange ---Change reason: 0 ---The key 'gemstone' was updated to value '24' ---UbiquitousKeyValueStoreDidChange: [AnyHashable("NSUbiquitousKeyValueStoreChangedKeysKey"): <__NSSingleObjectArrayI 0x280081c70>( gemstone )
widget Logs: --- widget health: 0, level: 0, experience: 0 ---ubiquitousKeyValueStoreDidChange ---Change reason: 0 ---The key 'experience' was updated to value '2' ---UbiquitousKeyValueStoreDidChange: [AnyHashable("NSUbiquitousKeyValueStoreChangeReasonKey"): 0, AnyHashable("NSUbiquitousKeyValueStoreChangedKeysKey"): <__NSSingleObjectArrayI 0x159e752f0>( experience ) ] --- widget health: 0, level: 0, experience: 2 ---ubiquitousKeyValueStoreDidChange ---Change reason: 0 ---The key 'gemstone' was updated to value '2' ---UbiquitousKeyValueStoreDidChange: [AnyHashable("NSUbiquitousKeyValueStoreChangeReasonKey"): 0, AnyHashable("NSUbiquitousKeyValueStoreChangedKeysKey"): <__NSSingleObjectArrayI 0x15bb0cd80>( gemstone ) ]
There's a possibility that each process is accessing a different store altogether. What's the value of your com.apple.developer.ubiquity-kvstore-identifier
for your app and your extension? Is it possible that they're different?
If the entitlement is resolving to the same value in both processes, can you reproduce the issue, take a sysdiagnose from your device, and submit a feedback so we can take a look at the logs?