Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URLForUbiquityContainerIdentifier always return nil

Simulator is in iOS8.1 and I'm using Xcode 6.1.1.

I have tried solutions from several different sources:

  • URLForUbiquityContainerIdentifier alway return nil
  • URLForUbiquityContainerIdentifier returns nil even if configured correctly
  • https://devforums.apple.com/thread/229509?

And nothing seems to work. My setup:

Entitlements and Capabilities: enter image description here

enter image description here

Code:

dispatch_async(dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
    NSURL *myContainer = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];

    // unarchive journal object from iCloud
    if (myContainer != nil) {
        NSString *filePath = [NSString stringWithFormat:@"%@/%@", myContainer.path, ARCHIVE_FILE_NAME];
        self.journal = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];

        // initialize journal from local storage if there's no iCloud archive
        if (self.journal == nil)
            [self initJournalFromLocalStorage];
        else
            [self.journal validateUserDefines];

        self.journal.cloudURL = myContainer;

        dispatch_async (dispatch_get_main_queue (), ^(void) {
            // On the main thread, update UI and state as appropriate
        });
    }
});

My Apple ID has iCloud enabled for both development and distribution; and I've tried creating and downloading a new provisioning profile.

I also tried changing iCloud.$(CFBundleIdentifier) to $(TeamIdentifierPrefix)$(CFBundleIdentifier) in .entitlements.

No matter what I do, URLForUbiquityContainerIdentifier always returns nil. Any help is appreciated!

like image 787
cohenadair Avatar asked Mar 18 '23 10:03

cohenadair


1 Answers

Do you have iCloud Drive enabled on the simulator?

From my own testing URLForUbiquityContainerIdentifier always returns nil if iCloud Drive is disabled with the iOS 8.1 Simulator. However, if you test on a device with the same setup it will return a valid value. Similarly, if iCloud Drive is enabled then the simulator will return the correct value. If you don't want to enable iCloud Drive then there isn't a workaround other than testing on a real device.

like image 185
Iain McManus Avatar answered Apr 02 '23 20:04

Iain McManus