iCloud / Entitlement issues with container identifier

Have you seen these errors?

The requested container identifier is not permitted by the client’s com.apple.developer.ubiquity-container-identifiers entitlement

and

NSFileManager URLForUbiquityContainerIdentifier:]: An error occurred while getting ubiquity container URL: Error Domain=LibrarianErrorDomain Code=11 “The operation couldn‚Äôt be completed. (LibrarianErrorDomain error 11 – The requested container identifier is not permitted by the client’s com.apple.developer.ubiquity-container-identifiers entitlement.)” UserInfo=0x125e70 {NSDescription=The requested container identifier is not permitted by the client’s com.apple.developer.ubiquity-container-identifiers entitlement.

 

Man this was frustrating. So Finally what I did was opened my provisioning profile on my mac using TextEdit. There is saw:

 

	<key>Entitlements</key>
	<dict>
		<key>application-identifier</key>
		<string>7T87CN95RT.com.domain.appname</string>
		<key>com.apple.developer.ubiquity-container-identifiers</key>
		<array>
			<string>3AN4TK8DRT.*</string>
		</array>
		<key>com.apple.developer.ubiquity-kvstore-identifier</key>
		<string>3AN4TK8DRT.*</string>
		<key>get-task-allow</key>
		<true/>
		<key>keychain-access-groups</key>
		<array>
			<string>7T87CN95R.*</string>
		</array>
	</dict>

I copied and pasted into the source code view of my entitlements file.


    
	<dict>
        <key>com.apple.developer.ubiquity-container-identifiers</key>
		<array>
			<string>3AN4TK8DRT.com.domain.appname</string>
		</array>
		<key>com.apple.developer.ubiquity-kvstore-identifier</key>
		<string>3AN4TK8DRT.com.domain.appname</string>
		<key>get-task-allow</key>
		<true/>
		<key>keychain-access-groups</key>
		<array>
			<string>7T87CN95RT.com.domain.appname</string>
		</array>
	</dict>

and HAZZZZAA:

    NSFileManager *fileManager = [NSFileManager defaultManager];

    NSString *bundleID = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
    NSLog(@"bundleID is: %@", bundleID);
    
    NSString *appID = [NSString stringWithFormat:@"3AN4TK8DRT.%@", bundleID];
    NSLog(@"appID is: %@", appID);
    
    NSURL *testCloudURL = [fileManager URLForUbiquityContainerIdentifier:appID];
    NSLog(@"testCloudURL is: %@", testCloudURL);

This actually produced a valid url.

This entry was posted in Uncategorized. Bookmark the permalink.