My application can successfully backup and restore data to the cloud.
I can view the data on the cloud if I go into iCloud -> Storage -> Manage Storage -> My App Name (with no iCon) -> I see my Folder I created.
I have bumped the "Bundle Version" (which is my build number and I bump before each upload).
Earlier versions did not have NSUbiquitous set
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.MyDomain.com.MyAppName</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>Documents</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>One</string>
</dict>
</dict>
I am backing up my Sqlite (CoreData) to the Folder on the cloud (I'm not syncing)
I have Key-Value storage and iCloud Documents enabled in Capabilities.
Using XCode 7 on ios 9.2.1
Is it because the files I'm backing up not normal "Documents".
I am under TestFlight and app has never been in App store yet.
What am I doing wrong?
I've seen some people say it has to wait until it goes into the App store
I had a couple of errors besides Mr. Schindler suggestions
CFBundleVersion must always be incremented and NEVER decremented even if you change CFBundleShortVersionString by a major rev.
I had an error in the case on one character in the NSUbiquitousContainers Key and did not exactly match the value of iCloud.$PRODUCT_BUNDLE_IDENTIFIER.
That key CANNOT use that symbol and must be reolved to the value of PRODUCT_BUNDLE_IDENTIFIER.
If PRODUCT_BUNDLE_IDENTIFIER = Foobar.com.MyApp then
NSUbiquitousContainers-> Key = iCloud.Foobar.com.MyApp
My erorr was I had NSUbiquitousContainers-> Key = iCloud.foobar.com.MyApp and I also tried NSUbiquitousContainers-> Key = iCloud.$PRODUCT_BUNDLE_IDENTIFIER both of which were wrong.
That combined with Mr. Schindler suggestions on the NSUbiquitousContainerName and having a root Documents folder fixed it.
I'm not 100% sure on the requirment of Documents folder but I did as suggested by Mr. Schindler and I end up in iCloud Drive with
The Value of NSUbiquitousContainerName as the top level folder name in iCloud Drive with a Folder in that folder called "Backup".
And I used this line to create that path.
return (FileManager.default.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents").appendingPathComponent("Backup"))!
So "Bumping" CFBundleVersion is not quite correct. It has to be bumped to a value higher than it ever was for the entire history of this product (when your meta data was set wrong).
I was reseting this value on major releases.
Everything else in the release process was working correctly except this iCloud Meta data getting propagated.
My only problem now is I can see the Data from another device in the same account but I cannot read the data from another device.
I can only read it from the same device that put it there.
Mr. Schindler is also correct on not needing to release it to app store. I could break it or fix it with the build number all locally using my iPhone in XCode.
Not sure about the rumor that it has to be released once to the app store (which it is now). But I doubt it that is needed. Also don't know status of using emulation.
Note also I use just a straight integer for my Build Number (a.k.a. CFBundleVersion) which I beleive is the correct way to use it.
I consider my version a concatination of CFBundleShortVersionString.CFBundleVersion
So with CFBundleShortVersionString = 2.0.3 and CFBundleVersion = 10 my Full version is 2.0.3.10
If I released a nwe major Rev 3.0.0 this Full Version of 3.0.0.0 would be illegal. It has to be 3.0.0.11
Some projects liek a continuing running build number and some like to reset it on major releases. Either is fine. But with Apple you can not decrement the CFBundleVersion. I've seen some developers put the full rev in CFBundleVersion e.g. CFBundleVersion = 3.0.0.11 but then you need to keep that in sync with CFBundleShortVersionString which is risky. I don't know if "bumping" CFBundleVersion to say CFBundleVersion = 3.0.0.11 would have also worked.