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

◇◆丶佛笑我妖孽 提交于 2019-11-28 06:36:55
Rick Andrews

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.

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!