Ennabah
Ennabah

Reputation: 2513

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:

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.

Upvotes: 5

Views: 4043

Answers (3)

Warren Stringer
Warren Stringer

Reputation: 1883

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

Upvotes: 6

Jerome
Jerome

Reputation: 2152

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.

Upvotes: 2

KKRocks
KKRocks

Reputation: 8322

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'.

Upvotes: 2

Related Questions