开发者

Problem registering file type through UTIs

I'm using AquaticPrime for开发者_开发问答 license generation in my app, and as the developer guide suggests I'm attempting to register a custom file extension, such that users can simply click on the license and my application will open it and can then verify the license.

To do this, I've added an exported UTI declaration to my Info.plist as follows:

<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeDescription</key>
        <string>MyApp License File</string>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.xml</string>
        </array>
        <key>UTTypeIdentifier</key>
        <string>com.mycompany.myapplicense</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>myapplicense</string>
            </array>
        </dict>
    </dict>
</array>

However, when I double-click on a file with that extension it doesn't open in MyApp, and nor does MyApp appear as one of the recommended apps to open the file type with. As well, when viewing the Info panel for the file, the filetype description as specified above doesn't appear.

Can anyone see anything wrong with my UTI declaration, or is there something else that I've missed?

Thanks


You also need a CFBundleDocumentTypes declaration.

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFile</key>
        <string>MyAppLicenseIcon</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>NSDocumentClass</key>
        <string>MyAppLicenseHandler</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.mycompany.myapplicense</string>
        </array>
    </dict>
</array>


To add to this, in my case I've had to also make sure that I was entering the proper format UTI as such:

        <key>UTTypeConformsTo</key>
    <array>
        <string>public.xml</string>

my file being a simple .plist, it still conforms to xml. You need to make sure you know which UTI format you conform to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜