Xcode 4 文档类型和导出的 UTI

发布于 2024-10-25 08:06:34 字数 1357 浏览 11 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

断桥再见 2024-11-01 08:06:34

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

如果要指定文件扩展名,需要添加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

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

I think the role and the file extension are missing.

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>

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>
摇划花蜜的午后 2024-11-01 08:06:34

您可以通过设置“文档类型”=> 来编辑“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.

戏蝶舞 2024-11-01 08:06:34

我只是查看了旧的 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文