今天调试iCloud的时候遇到了这个问题
*** -[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=0x1d56a5b0 {NSDescription=The requested container identifier is not permitted by the client's com.apple.developer.ubiquity-container-identifiers entitlement.}
查询不到结果
查询的URL的代码是这样的:
NSString *containerId = @"com.mycompany.myapp";
NSURL *iCloudURL = [[fileManager URLForUbiquityContainerIdentifier:containerId];
NSLog(@"%@", [iCloudURL absoluteString]);后来通过上网查询后,发现是少了一个前缀名
前缀得在provision文件里找<dict>
<key>application-identifier</key>
<string>AAAAAA.com.mycompany.*</string>
<key>com.apple.developer.default-data-protection</key>
<string>NSFileProtectionComplete</string>
<key>com.apple.developer.pass-type-identifiers</key>
然后把那个前缀加进去就正常了
NSString *containerId = @"YYYYYYY.com.mycompany.myapp";
NSURL *iCloudURL = [[fileManager URLForUbiquityContainerIdentifier:containerId];
NSLog(@"%@", [iCloudURL absoluteString]);

被折叠的 条评论
为什么被折叠?



