Swift write/save/move a document file to iCloud drive

I believe I've found a way to get everything back in sync without constantly having to "bump" my bundle number. I've tried this multiple times while making changes within the "capabilities" area of key-value storage/iCloud Documents/CloudKit and it seems to work each time.

  1. Sign out of iCloud on your Mac
  2. Sign out of iCloud on your Simulator
  3. Sign back into iCloud on your Mac
  4. Sign back into iCloud on your Simulator
  5. Do a clean build from XCode (Shift-Cmd-K)

This appears to reset the synchronization of the folder structures when you're App is writing to your iCloud Documents directory - without having to touch your bundle number. It takes a little longer to do it, but I'm a little OCD and kinda prefer my initial App launch to start with a 1!


I had this problem. I followed the advice here and I found that my Info.plist key was not correct. Once I changed it to iCloud.MY_BUNDLE_IDENTIFIER (i.e. copy the string from the CFBundleIdentifier key higher in Info.plist) it all started working.

Removing the .com from your key may fix your issue.


FWIW:

I also found out that the name of the project within the bundle ID is important.

My project bundle ID was something like the following: aaa-bbb-ccc-ddd

I could not get the iCloud working.

Then I renamed it to: aaa-bbb.ccc-ddd

It started working.