Search code examples
iphoneicloud

Sharing iCloud data between an iOS app and an OSX app with NSUbiquitousKeyValueStore


I've built an app that is intended to run (and share iCloud data) on both the iPhone and on Mac OSX. The two apps have different bundle identifiers (ending in .iOS and .OSX respectively), but I have set Ubiquity Containers in the iCloud settings to be the same:

enter image description here

Unfortunately, after synchronizing with NSUbiquitousKeyValueStore, it appears that data created on one device is not available on the other.


Solution

  • I solved this problem by editing the .entitlements file which was automatically created by XCode. In addition to the "ubiquity containers", there is a row in this file called "iCloud Key-Value Store" which can be modified to use the same bundle path. Once changed, I had to clean/rebuild both apps and viola! The data was shared.