Xcode 4 文档类型和导出的 UTI
我在使用 Xcode 4 时还有一个问题。我真的很喜欢新的 IDE,但有一些东西我还没有开始工作。一件事是使用 Xcode 4 注册文档类型。 我用旧的方式通过plist文件尝试了它,但它不起作用。 (意味着我无法使用我的应用程序打开文件)但我现在不知道如何使用 Xcode 4 的界面进行设置。
我最新的尝试如下所示:(复制了 info.plist 中从 Xcode 生成的条目)
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>Configuration File</string>
<key>UTTypeIdentifier</key>
<string>com.myname.projec.iws</string>
</dict>
</array>
并且:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>AnIcon-320</string>
</array>
<key>CFBundleTypeName</key>
<string>Config File</string>
<key>LSItemContentTypes</key>
<array>
<string>com.myname.projec.iws</string>
</array>
</dict>
</array>
这不起作用。邮件中的文件没有使用我的应用程序打开的选项。
有没有人有 Xcode 4 的工作示例或教程。我不知道如何让它发挥作用。
桑德罗
I have an other problem with Xcode 4. I really like the new IDE but there are a few things I didn't get to work yet. One thing is to register Document Types with Xcode 4.
I tried it with the old way through the plist file, but it didn't work. (Means I couldn't open a file with my app) But I don't now how to set it up with the interface of Xcode 4.
My latest try looks like this: (Copied the entry made from Xcode in the info.plist)
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>Configuration File</string>
<key>UTTypeIdentifier</key>
<string>com.myname.projec.iws</string>
</dict>
</array>
and:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>AnIcon-320</string>
</array>
<key>CFBundleTypeName</key>
<string>Config File</string>
<key>LSItemContentTypes</key>
<array>
<string>com.myname.projec.iws</string>
</array>
</dict>
</array>
This does not work. The file in Mail doesn't have the option to open with my app.
Does anyone have a working example with Xcode 4 or a tutorial how to do it. I don't have any further Idea how to get it work.
Sandro
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为角色和文件扩展名丢失了。
如果要指定文件扩展名,需要添加UTTypeTagSpecification:
对于角色,需要添加CFBundleTypeRole:
I think the role and the file extension are missing.
If you want to specify a file extension, you need to add UTTypeTagSpecification:
For the role, you need to add CFBundleTypeRole:
您可以通过设置“文档类型”=> 来编辑“com.mycompany.myfiletypename”的等效内容“项目 0”=> “文档操作系统类型”=> “项目 0”。
默认值为“???”您可以将其更改为“com.mycompany.myfiletypename”。
我认为其他属性不言自明。
You can edit the equivalent of your 'com.mycompany.myfiletypename' by setting "Document Types" => "Item 0" => "Document OS Types" => "Item 0".
The default value is "????" which you can change to "com.mycompany.myfiletypename".
I think the other properties speak for themselves.
我只是查看了旧的 .plist 文件,然后将键和值剪切并粘贴到从 Xcode3 版本导入的 Xcode 4 项目中的新文件中。当它出现时,它显然“丢失”了 .plist 中有关 UTI 的一些信息。然而,当我从 Xcode3 制作的 .plist 中粘贴丢失的键/值时,新值起作用并且它们出现在 GUI 中,因此您现在可以“浏览”GUI 并查看内容在哪里。对 GUI 进行了逆向工程,但它确实有效。
I just looked at my old .plist file and cut and pasted the keys and values into the new one in Xcode 4 project that had been imported from an Xcode3 version. It apparently "loses" some of the info in the .plist for UTI's when it comes over. However, when I pasted the missing keys/values back in from .plist made with Xcode3, the new values worked AND they appear in the GUI so you can now "browse" the GUI and see what goes where. Kind of reverse engineering the GUI but it works.