Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URLForUbiquityContainerIdentifier returns nil even if configured correctly

I am having the problem, that URLForUbiquityContainerIdentifier is returning nil in some cases even if the user has set up everything correctly in the settings. My code:

dispatch_async(someQueue, ^{

    if (![[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]) {
        ErrLog(@"iCloud container not available.");
        return;
    }

    dispatch_async(dispatch_get_main_queue(), ^{
       [...]
    });

});

Does anybody came across the same problem? I am setting nil as the container identifier which should work according to the Apple docs, but I am not so convinced anymore about that. Also this code works fine for the majority of users, but somehow not for everybody.

like image 870
Martin Hering Avatar asked Dec 14 '11 13:12

Martin Hering


3 Answers

Check that you have enabled iCloud containers in your entitlement. The containers are not added by default when you enable entitlements. Click the "+" sign in Target/Summary/Entitlements to add your appId.

like image 179
barksten Avatar answered Sep 26 '22 08:09

barksten


iPad mini with iOS7. I just have experienced that URLForUbiquityContainerIdentifier suddenly started to return nil. I tried restarting the device, but it didn't help.

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

like image 34
neoneye Avatar answered Sep 23 '22 08:09

neoneye


If anyone is having the same problem using the iOS8 Betas, there seems to be a bug with the way the Entitlements are generated in Xcode 6. I was banging my head against this for days until coming across this post in the Apple Developer Forums: https://devforums.apple.com/thread/229509?

Essentially, Xcode generates a key named com.apple.developer.icloud-container-identifiers when it should be com.apple.developer.ubiquity-container-identifiers (ubiquity, not icloud). It may also have the value set as iCloud.$(CFBundleIdentifier) when it should be $(TeamIdentifierPrefix).$(CFBundleIdentifier).

Of course this may get fixed in the next Beta but for anyone as confused as me I hope this helps.

like image 26
SeanR Avatar answered Sep 22 '22 08:09

SeanR