The iOS app I'm working on exports a UTI. The relevant parts of the Info.plist
look like this:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.xml</string>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>GPX Document</string>
<key>UTTypeIdentifier</key>
<string>de.company.app.gpx</string>
<key>UTTypeSize320IconFile</key>
<string>Doc320.png</string>
<key>UTTypeSize64IconFile</key>
<string>Doc64.png</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gpx</string>
</array>
</dict>
</dict>
</array>
I want the app to handle GPX files via "Open in..." dialogues, so there's also a document type definition (which references the UTI) in the same PLIST:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>Icon29.png</string>
<string>Icon58.png</string>
</array>
<key>CFBundleTypeName</key>
<string>de.company.app.gpx</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>de.company.app.gpx</string>
</array>
</dict>
</array>
When opening GPX files in Safari, it displays the icon I specified under CFBundleTypeIconFiles
, i.e., Icon58.png
on a retina device. The app also allows imports via the UIDocumentPickerViewController class introduced in iOS 8, and while the UTI definition works fine for filtering relevant files in iCloud Drive, it does not show any of my specified artwork:
I have ensured all the referenced image files (Icon29.png
, Icon58.png
, Doc64.png
, Doc320.png
) are indeed in the app bundle's root directory. The numbers in their names indicate their height in pixels. The Doc...
files are squares, the other two follow this specification (iPhone only).
I've got basically two questions:
1) How do I make the UIDocumentPickerViewController display custom icons for our UTIs?
2) Are there any other use cases where UTTypeSize64IconFile
and UTTypeSize320IconFile
are used?
I believe you are using the wrong size icons in your CFBundleTypeIconFiles key. The size you are using are for the settings icon.
To test my theory, please add a few more files with different sizes. Plus all icons are square. The image you have in your question looks rectangular.
According to the section Icon and Image Design --> App Icon:
Document Icons
If your iOS app creates documents of a custom type, you want users to be able to recognize these documents at a glance. You don't need to design a custom icon for this purpose because iOS uses your app icon to create document icons for you.
And Excerpt from App Icons:
App icon (required) (iPhone)
This is the main icon for apps running on iPhone and iPod touch in iOS 7 and later.
Settings icon (All devices)
Unfortunately, the answer is that it cannot be done unless your app has control over how these files are written to disk. In that case, you can subclass UIDocument
and write out thumbnails. Here is the original answer posted by an Apple engineer, posted on the Apple developer forums (login required). It includes a code sample to illustrate how it's done.
I haven't found an answer to the second part of my question yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With