The Time Consuming Nightmare:
I believe I've been meticulous and done everything right in terms adding iCloud capabilities and creating an app iCloud container, wherein my goal is to give have an app-specific folder visible and accessible on my iDrive.
Yet, after hours of dinking around with it, I still can't get the app's "ubiquity container" to appear on iDrive. I've checked the configuration many times and everything looks perfect. I've read everything I can find. Some people say they've seen issues like this resolve after a day or two, when it spontaneously started working.
But that's a real ding to my development schedule. Really can't be sitting around twiddling my thumbs waiting on a guessing game that may not pay off, only to potentially wind-up back at the drawing board after two wasted days, just to learn one data point - that waiting 2 days didn't work.
Overall, iOS App's iCloud configuration is functional:
My app is able to create a directory hierarchy, and create some files in the container, and everything is consistent and behaves as expected.
While the folder (container) isn't visible on the iDrive, the data I've been creating and working with in my iPhone, my Mac is secretly maintaining an iCloud mirror of it here:
~/library/Mobile\ Documents/iCloud~com~MyDomain~MyApp
The data written by my iOS app into the directories of the container, are kept hidden by the ICloud infrastructure, at least on the Mac side (which adds '.' as a prefix to the filename, and '.icloud' as a suffix). So each file is hidden to people doing a simple 'ls' from the command line on macOS, but everything works inside the iOS app.
My configuration:
@matt documented the standard configuration very well in this answer.
- I've ensured it all looks like that.
Note: The iCloud container identifier appears twice in the entitlements file, and all that is edited/managed automatically when the iCloud capability is added or removed or modified in the XCode App's target's Signing and Capabilities tab, configuration screen. AFAICT there's no need, at least in XCode 14.3 to manually edit the entitlements file.
The Bundle ID is correct.
The following are showing up on the Apple Developer's site, and look correct and match the App's configuration in XCode (and the plist and entitlements file):
-
- Development Certificate
-
- App ID
-
- Provisioning profile
ICloud container identifier = "iCloud." + App ID
"/Documents" appended to ubiquity container URL (my dir tree is beneath that).
I've bumped the bundle version and build #'s many times throughout the process but it doesn't seem to help.
What might be going on:
Since so much does work, I believe I've nailed most if not all of the iCloud configuration steps.
I'm becoming suspicious this is a bug on Apple's side. That it is a a vestigial effect of me changing the container name. Theoretically I should be able to change the container, because on the Apple Developer site, in the App ID capabilities iCloud configuration section, you can manage and edit the iCloud container list.
But I've read a report from a user who says that if the provisioning profile used a previous app container name, publishing a new container won't work for that provisioning profile.
And this app used to have a different name, different provisioning profile and an iCloud container was created and the folder successfully published on iDrive, under the old iCloud container identifier.
What may have been the problem in my case:
After renaming the app, and corresponding profile and identifiers, I built the app and launched it, but unfortunately I'd forgotten to update the container under the NSUbiquitousContainers key in Info.plist. So I inadvertently was trying publish the the old container id whereas my app was configured with a newer container name. They were mismatched in other words.
I wonder if that polluted the iCloud for bundle ID or provisioning profile? But after fixing Info.plist, why wouldn't that resolve it after bumping the bundle version and build'#s?