ios - iCloud 在设备重启之前无法识别包

标签 ios icloud uidocument

我们基于 UIDocument 的应用程序在 info.plist 的“导出类型 UTI”和“文档类型”下定义了一个自定义文档类型。我们根据 Apple 文档在 iCloud 无处不在的容器中创建 UIDocuments。在设备重新启动之前,文档不会注册为包。这只会在第一次安装该应用程序时发生。重新启动后,创建的任何新文档都将被视为我们自定义类型的包(应该如此)。

Info.plist 包含以下条目:

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>Sample Doc</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.sampledoc.tst</string>
            </array>
            <key>LSTypeIsPackage</key>
            <true/>
        </dict>
    </array>
<key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>com.apple.package</string>
            </array>
            <key>UTTypeDescription</key>
            <string>Sample Doc</string>
            <key>UTTypeIdentifier</key>
            <string>com.sampledoc.tst</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>tst</string>
                </array>
            </dict>
        </dict>
    </array>

当元数据查询返回结果时,contentType 将为“dyn”。 (这是问题所在)。设备重启后,新文档的 contentType 将为 com.sampledoc.tst(这是预期值)。

有其他人遇到过这个问题吗?任何帮助将不胜感激。

最佳答案

我在苹果论坛也发过同样的问题,下面是苹果的回复

感谢您咨询 Apple 全局开发者技术支持。 我回复您是为了让您知道我已收到您的技术协助请求。

我查看了您的示例项目,但没有找到“CFBundleTypeExtensions”的条目。

您的“UTExportedTypeDeclarations”定义正确,但对于“CFBundleDocumentTypes”,您缺少“CFBundleTypeExtensions”条目。

<key>CFBundleTypeExtensions</key>
<array>
    <string>tst</string>
</array>

添加该条目,您应该会看到您的包裹已被识别。

关于ios - iCloud 在设备重启之前无法识别包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34019136/

相关文章:

ios - 获取从 UIWebView iOS 触发的请求的响应?

objective-c - 单点触控 : The correct way to override UIViewController method

ios - iCloud - NSMetadataQuery 返回旧结果,显示已删除的文件

ios - iCloud 和 CoreData : Notification when changed to iCloud Store (First Launch with existing iCloud Data)

ios - 当用户滚动条形图时,我可以调用 SwiftCharts 中的委托(delegate)吗?

ios - 保持 UIStackView 位于比例 UIStackView 内的正下方、顶部 UIStackView

iphone - 如何删除 iCloud 文件?

ios - 跨设备检测 iCloud 中文档删除的正确方法?

ios - 带有自动保存的 UIDocument 何时保存文件

swift - UIDocument 中的 saveToURL 返回 false