5

I'm trying to get the url for my contrainer ID but the method keeps returning nil.

I've done the following:

  • Enabled iCloud Key-value storage in Xcode capabilities.
  • testing on a physical device.
  • iCloud, and iCloud Drive turned on in the physical device.
  • Made sure that iCloud Key-Value Store is added to the entitlements file.

My code is:

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 looked for almost all of the questions that are related to this issue and tried the answers but it's not working.

Ennabah
  • 2,303
  • 2
  • 20
  • 39

3 Answers3

5

For Xcode 9.2, checking this option worked: enter image description here

Warren Stringer
  • 1,692
  • 1
  • 17
  • 14
1

iOS10.3

I had same problem, fix it by following steps: 1.go to physical device's setting -> iCloud. turn off iCloud Drive and turn it on again, find your app in iCloud Drive, turn off and turn on. 2.shut down your device, and restart it.

Then it worked, I'm not sure which part make it worked, hope for help.

Community
  • 1
  • 1
Jerome
  • 2,114
  • 24
  • 24
0

Try this :

Inside the Settings app, under the 'iCloud' menu. I noticed that 'Documents & Data' was set to Off.

Solution was to change ('Documents & Data' to 'On'.

KKRocks
  • 8,222
  • 1
  • 18
  • 84