Registering an icon for my application's document type

Try putting the icon name in the CFBundleTypeIconFile key in the CFBundleDocumentTypes array, not in the UTExportedTypeDeclarations array.

And of course make sure that "My-file-icon.icns" is in your target's Copy Bundle Resources build phase and is being copied into Contents/Resources in your app's bundle.


I've been trying to do this in Xcode 11 and it's been a challenge. There are lots of answers here on SO to questions like this but I couldn't find one that had everything I needed to get this working. I'll try to do that here.

Technical Q&A QA1587 Although this is a bit old I think it has everything required but it's a bit vague in some spots like when it says Provide an icon for the document.

I thought I could make it work with an icon in Assets.xcassets but it didn't work for me until I provided an icns file. I took the 1024x1024 png app icon and converted it to an icns here at cloudconvert. Then I added that icns to my project. I don't think it matters where you put it. I put it just below the top level. It's circled in the image below.

enter image description here Follow the arrows in the image and you end up at the Info tab. I tapped the Add button to create a Document Type and filled it in as shown. When you tap the Add button in the icon section it will ask you for an icns file. Once I had mine in the project it appeared in the window and I could select it.

Same for Configured UTIs.

That was it. In Files, Messages, or Mail the icon appears.


Your UTI declaration in the Info.plist appears to be correct, however I noticed an other issue. If you application is a document-based application you need to replace the NSString in following entry with your NSDocument subclass:

<key>NSDocumentClass</key>
<string>NSString</string>

For example it's "SKTDocument" in Sketch:

<key>NSDocumentClass</key>
<string>SKTDocument</string>

Edit: Please also make sure to use your own reverse domain name for your exported UTIs. This ensures that UTIs are unique. For example its com.mindnode.MindNode.MindNodeDocument in my case.