Search code examples
iosobjective-cswiftswift3icloud

url(forUbiquityContainerIdentifier) returns nil


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.


Solution

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