I have these two apps, one iOS and one Mac OS X each with a different Bundle ID.
In order for the two apps sync and share the files I had to add the ubiquity container of the iOS app to the list of ubiquity containers in the Mac OS X app.
In the Xcode summary for the Mac OS X app I can't add its own Bundle ID as a ubiquity container. The Mac OS X app will store new added files in its own ubiquity, and so they're inaccessible to the iOS app.
How can I correctly set up both apps so they share and sync all added files using the same ubiquity container?
For my own iOS/Mac app pair, I just had my iOS app with the BundleID com.alexanderwinn.Example
and the Mac app with com.alexanderwinn.ExampleMac
, but they both shared the ubiquity container com.alexanderwinn.Example
. Neither of them, not even the Mac version, had a ubiquity container based on the Mac BundleID. I'm a beginner so I can't fully detail the reasoning behind how everything works and breaks, but it's working fine for me!
To allow multiple apps to access the same data store / ubiquity container, you'll need to do a few things. First, you'll need to open up your Xcode project and follow these instructions (official Apple document here):
To start using iCloud in all of your apps with the same iCloud container you'll need to create URLs with your team ID and container ID. Apple sums this up nicely:
To retrieve a URL for a ubiquity container, you must pass the fully qualified string to the NSFileManager method URLForUbiquityContainerIdentifier:. That is, you must pass the complete container identifier string, which includes your team ID, that you see in the .entitlements property list file. You can pass nil to this method to retrieve the URL for the first container in the list.
Then, setup something called an iCloud Display Set in iTunes Connect. This allows you to create a Display Set ID which can then be shared between your apps so they can access the same data. Here are a few useful links to get you started:
Here's how to setup an iCloud Display Set:
Create New
to add a Display Set Then just attach it to your apps! Hope this helps, good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With