Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do ubiquity containers work between iOS and Mac OS X apps?

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?

like image 687
fundidor Avatar asked Nov 03 '22 04:11

fundidor


2 Answers

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!

like image 185
Nerrolken Avatar answered Nov 08 '22 16:11

Nerrolken


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):

  1. Open your Xcode project and then navigate to the project target settings. Click on the Capabilities tab to open up the project settings for extra Apple services. Xcode 5.0 Project Capabilities
  2. Then turn the iCloud option ON. The Ubiquity Container ID should be the same in every app which you need to share data with. The bundle ID's of apps you share data with do not have to be the same, but they both need the same Ubiquity Container ID and team ID. Xcode iCloud project ubiquity container
  3. 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:

  • What's the use of iCloud Display Sets?
  • Apple Docs

Here's how to setup an iCloud Display Set:

  1. Go to iTunesConnect and open the Manage Applications Section
  2. At the bottom of the page, follow the link to iCloud Display Sets
  3. Click Create New to add a Display Set
  4. Fill out the required information, including the ID:
    enter image description here

Then just attach it to your apps! Hope this helps, good luck.

like image 43
Sam Spencer Avatar answered Nov 08 '22 14:11

Sam Spencer