Url (forUbiquityContainerIdentifier) returns nil
I am trying to get the url of my ID, but the method keeps returning nil
.
I did the following:
- Enabled storage of iCloud key values in Xcode capabilities.
- testing on a physical device.
- iCloud and iCloud Drive are enabled on the physical device.
- Make sure to
iCloud Key-Value Store
add permissions to the file.
My code:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Override point for customization after application launch.
let cloudURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)
print(cloudURL as Any)
return false
}
I have searched for almost all questions related to this problem and tried to answer, but it doesn't work.
+3
source to share
3 answers
iOS10.3
I had the same problem, fix it by following these steps: 1.go to set up a physical device -> iCloud. turn off iCloud Drive and turn it on again, find the app in iCloud Drive, turn it off and on. 2. Turn off the device and restart it.
Then it worked, I'm not sure which part worked, hope for help.
0
source to share