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