3
votes

I have written a simple test application (Mac/Cocoa) to connect to the Key-Value store in iCloud. I seem to be falling at the first fence.

You can see the code for my simple app here and you'll see that I am not getting a URL back from "URLForUbiquityContainerIdentifier" call.

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
    if (!ubiq)
        NSLog(@"No iCloud");
    else
        NSLog(@"Yes iCloud");
}

Screenshot of the app running with output:

enter image description here

In term of trying to see if I've everything setup correctly I looked at the setup of my App Id (Test app is called Radio) in the developer provisioning centre:

enter image description here

So that seemed to be ok. Then I re-created my provisioning profile (called Radio Dev 2) and checked that it was using the correct App Id:

enter image description here

Ok, so that also seemed to be ok. I then checked that entitlements was switched on and Key-Value container was activated:

enter image description here

So they are activated. I then took a look at the file itself, just to see if anything jumped out:

enter image description here

So I couldn't see anything jumping out at me in the entitlements file. Lastly, I confirmed that I was signing the build with the correct cert using the provisioning profile that I expected:

enter image description here

I was happy enough with that.

So I'm stumped. I've regenerated everything, etc, to no avail.

I'd really appreciate if anybody has any ideas. Have I missed anything?

3
I have to wait 2 days for me to be able to provide my own answer, but it would appear that turning on the iCloud Containers is required for this code to work, even if its not being used. - Damien
it is being used thats where the key value store lives - deleted_user

3 Answers

4
votes

Damien's comment on the question had the solution for me. For anyone using Xcode 4.5, you need to click the + below the Ubiquity Containers box. Until I did that, nothing worked.

Xcode

0
votes

I faced same problem. I noticed that in my device setting, I didnt logged in my icloud account. once done with adding my account iCloud. The issue was resolved.

0
votes

In my case, I implement the Parts "Add Document Type" and "Add Exported UTI" of Section "Configuring your Project for iCloud". And, it will not keep return nil anymore.

http://www.raywenderlich.com/12816/icloud-and-uidocument-beyond-the-basics-part-3