Xcode 4文档类型和导出的UTI [英] Xcode 4 Document Types and Exported UTIs

查看:144
本文介绍了Xcode 4文档类型和导出的UTI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Xcode 4还有另一个问题.我真的很喜欢新的IDE,但是有些事情我还没有开始工作.一件事是用Xcode 4注册文档类型. 我通过plist文件的旧方法尝试了一下,但是没有用. (意味着我无法使用我的应用程序打开文件),但是现在我不知道如何使用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.

我最近的尝试是这样的:(已复制从info.plist中的Xcode生成的条目)

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>

和:

<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>

这不起作用. Mail中的文件没有打开我的应用程序的选项.

This does not work. The file in Mail doesn't have the option to open with my app.

任何人都没有使用Xcode 4的有效示例或如何使用它的教程.我没有任何进一步的想法如何使其工作.

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

推荐答案

我认为角色和文件扩展名丢失了.

I think the role and the file extension are missing.

如果要指定文件扩展名,则需要添加 UTTypeTagSpecification :

If you want to specify a file extension, you need to add UTTypeTagSpecification:

    <key>UTExportedTypeDeclarations</key>

<array>

    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.text</string>
        </array>
        <key>UTTypeDescription</key>
        <string>my document type</string>
        <key>UTTypeIdentifier</key>
        <string>com.mycompany.myfiletypename</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>iws</string>
            </array>
        </dict>
    </dict>

对于角色,您需要添加 CFBundleTypeRole :

For the role, you need to add CFBundleTypeRole:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>My file</string>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>document-320.png</string>
            <string>document-64.png</string>
        </array>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.mycompany.myfiletypename</string>

        </array>
    </dict>
</array>

这篇关于Xcode 4文档类型和导出的UTI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆