URLForUbiquityContainerIdentifier为有效的containerId权利返回nil

时间:2017-08-31 07:35:44

标签: ios xcode icloud

我无法为我的生活获取URLForUbiquityContainerIdentifier,以便在iOS上为我的iCloud容器工作。我有:

将iCloud容器添加到应用程序&开发人员门户网站上的配置文件。

在Xcode中设置包含容器的iCloud权利。

验证已签名的应用包中的团队ID和权利:

turin:pkdiagram patrick$ codesign -d --ent :- build/ios/Debug-iphoneos/Family\ Diagram.app

Executable=/Users/patrick/dev/pkdiagram/build/ios/Debug-iphoneos/Family Diagram.app/Family Diagram
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>application-identifier</key>
    <string>8KJB799CU7.com.vedanamedia.familydiagram</string>
    <key>aps-environment</key>
    <string>development</string>
    <key>com.apple.developer.icloud-container-identifiers</key>
    <array>
        <string>iCloud.com.vedanamedia.familydiagram</string>
        <string>iCloud.com.vedanamedia.Family-Diagram</string>
        <string>iCloud.com.vedanamedia.PKDiagram</string>
        <string>iCloud.com.vedanamedia.familydiagrammac</string>
    </array>
    <key>com.apple.developer.icloud-services</key>
    <array>
        <string>CloudDocuments</string>
    </array>
    <key>com.apple.developer.team-identifier</key>
    <string>8KJB799CU7</string>
    <key>com.apple.developer.ubiquity-container-identifiers</key>
    <array>
        <string>iCloud.com.vedanamedia.familydiagram</string>
        <string>iCloud.com.vedanamedia.Family-Diagram</string>
        <string>iCloud.com.vedanamedia.PKDiagram</string>
        <string>iCloud.com.vedanamedia.familydiagrammac</string>
    </array>
    <key>com.apple.developer.ubiquity-kvstore-identifier</key>
    <string>8KJB799CU7.com.vedanamedia.familydiagram</string>
    <key>get-task-allow</key>
    <true/>
</dict>
</plist>

确认设备上确实启用了iCloud:

if([NSFileManager defaultManager].ubiquityIdentityToken) {

使用。:

查询文档路径
    NSString *teamID = @"8KJB799CU7"; // replace with your real Team ID
    NSString *bundleID = @"iCloud.com.vedanamedia.familydiagram";
    NSString *containerID = [NSString stringWithFormat:@"%@.%@", teamID, bundleID];
    NSURL *_iCloudRoot = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:containerID];

似乎没什么用,_iCloudRoot总是零。还有什么我可以检查的吗?我已经在这几个小时了。

1 个答案:

答案 0 :(得分:0)

即使文档声明将TEAMID.CONTAINER作为URLForUbiquityContainerIdentifier传递给指定容器,但我只是传递了容器的包标识符。