Search code examples
iosiphonefile-import

Associate a File Type with my iOS App: No Image for file


I associated a custom file-type with my iphone-app and everything works fine: When selecting a file in mail it asks me to open that file with my app.

But, it only shows a default image for that file and not my provided 22x29px PNG.

Can you see my mistake?

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFile</key>
            <string>DocIcon.png</string>
            <key>CFBundleTypeName</key>
            <string>kmk custom data type</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.mycomp.document.kmk</string>
            </array>
        </dict>
    </array>
...
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.text</string>
            </array>
            <key>UTTypeDescription</key>
            <string>My App File</string>
            <key>UTTypeIdentifier</key>
            <string>com.mycomp.document.kmk</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <string>kmk</string>
            </dict>
        </dict>
    </array>

The docIcon.png is 22x29px and has a retina-brother in 44x58px called [email protected], but thats not referenced anywhere. I think this could be the error, but I don't know how to fix that.


Solution

  • in Xcode 5, select your "TARGET", go to tab "INFO", Have a look in "Document Types" : Did you set your icon here ? Now, check if in exported / imported UTI you set the identifiers = the Type you put in "Document Types".

    especially check :

    com.mycomp.document.kmk != com.mycomp.document.kpk

    edit : (removed)

    edit 2 :

    Based on apple doc here

    you should set Exported UTIs :

    identifier = com.mycomp.document.kmk

    conform to = public.data

    Additional exported UTI properties

    UTTypeTagSpecification (Dictionary)

      public.mime-type = Application/XXX    (replace XXX vita your app name)
      public.filename-extension = kmk       (extension without the dot)
    

    you'll found that in your info.plist at UTExportedTypeDeclarations

    <key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.data</string>
            </array>
            <key>UTTypeDescription</key>
            <string>YOUR DESCRIPTION</string>             (to be changed)
            <key>UTTypeIdentifier</key>
            <string>com.mycomp.document.kmk</string>
            <key>UTTypeSize320IconFile</key>
            <string>Icon@2x</string>
            <key>UTTypeSize64IconFile</key>
            <string>Icon</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <string>kmk</string>
                <key>public.mime-type</key>
                <string>Application/YOUR-APP-NAME</string>  (to be changed)
            </dict>
        </dict>
    </array>
    

    Edit 3 :

    netshark1000 have report that Application/YOUR-APP-NAME have solve the issue.

    Hop this can help others.