1 year ago
#306603
Vyacheslav Hrasiuk
NSUbiquitousKeyValueStore API not working on macOS Monterey
My app uses iCloud key-value storage objective-c api as follows:
NSUbiquitousKeyValueStore* iCloudStorage = [NSUbiquitousKeyValueStore defaultStore];
[iCloudStorage synchronize];
[iCloudStorage setString:@"Test" forKey:@"TestStringKey"];
[iCloudStorage synchronize];
NSString* value = [iCloudStorage stringForKey:@"TestStringKey"];
To use this api i add the following entitlement to the entitlements file:
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
Also, I've enabled iCloud support in Certificates, IDs, and Profiles on developer.apple.com for my app identifier, so it looks like as described in the iCloud Key-Value Storage documentation. The problem is that this code works without problems on all MacOS versions before Monterey, but the code does not work on the Monterey version - it is impossible to save the string or retrieve it from the storage and in the logs I see the following messages:
2022-03-15 17:41:17.119843+0300 [Connection] Unable to find entitlement for KVS store
2022-03-15 17:41:17.119888+0300 [Connection] Trying to initialize NSUbiquitousKeyValueStore without a store identifier. Please specify a store identifier in your entitlements or initializer.
After re-reading the documentation for this api and making sure that I have everything set up as described there, I did not find a solution to the problem, so I ask for help.
objective-c
macos-monterey
icloud-api
0 Answers
Your Answer