Stumped that [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil] keeps returning nil

cocoa, icloud, macos, objective-c, xcode

Solution

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.

Problem

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: 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: 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: Ok, so that also seemed to be ok. I then checked that entitlements was switched on and Key-Value container was activated: So they are activated. I then took a look at the file itself, just to see if anything jumped out: 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: 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?

Original source