我们基于 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/