How do I register a custom filetype in iOS

I hope it’s okay if I dump in that part of my projects info.plist without much further explanation. I think it’s pretty much self-explanatory.

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>Icon-iPad-doc320.png</string>
            <string>Icon-iPad-doc.png</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>MyAppName File</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <!-- my app supports files with my custom extension (see UTExportedTypeDeclarations) -->
            <string>com.myurl.myapp.myextension</string>
            <!-- and csv files. -->
            <string>public.comma-separated-values-text</string>
        </array>
    </dict>
</array>



<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.data</string>
        </array>
        <key>UTTypeDescription</key>
        <string>MyAppName File</string>
        <key>UTTypeIdentifier</key>
        <string>com.myurl.myapp.myextension</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <string>myextension</string>
            <key>public.mime-type</key>
            <string>application/octet-stream</string>
        </dict>
    </dict>
</array>

Leave a Comment