Mark Cowan
Mark Cowan

Reputation: 93

How can I add a custom document icon to my documents in a document-based Mac app?

To get custom document icons, do I need to add a new “Icon” set in Xcode’s Assets.xcassets folder by selecting Editor > Add Assets > App Icons & Launch Images > New macOS Generic Icon? Or do I just add a .icns file with appropriate sizes to the Assets.xcassets folder?

Also, I can’t find in the macOS Human Interface Guidelines what a custom document icon should look like. Most of them resemble Apple’s generic document icon with the custom file extension added at the bottom in all caps (TXT, DOCX, etc.). Do we copy Apple’s generic document icon and modify it by adding our own graphic (centered) and extension name across the bottom of it? (If so, where can that template be found?) Do we create another version of that same icon with a preview of the first page of our document (instead of the graphic)—or is that handled by the system automatically? I’ve seen both types of document icons in Finder windows.

If there is any documentation that gives a workflow for creating custom document icons for a Mac or iOS app, I would truly appreciate a reference. I’ve done an enormous amount of reading, but this is my first app. So a step-by-step answer would be most helpful.

Upvotes: 2

Views: 1557

Answers (1)

Dirk
Dirk

Reputation: 2425

Using Assets.xcassets does not really work that well (still with Xcode 10). I'd suggest the following steps:

  • Generate a ICNS file out of a PNG or TIFF file you designed for your documents, using one of the icon generator tools available in the App Store (see below on how to design a document icon).
  • Drag the ICNS file into your project (select copy if needed).
  • Switch to the target settings of your project, select the Info tab. There should be an entry in Document Types.
  • Select the name of the ICNS file in the drop down menu next to Icon in the document entry.

This should do it. You should see the icon in the document entry. Sometimes the Finder does not display this right away when you save a document, but maybe after a reboot.

On getting a generic document icon: If you save a document from your app without applying an icon to it first, it will show the generic icon. Do a "Get Info" from Finder, select the small icon next to the name on top of the info window and paste the TIFF into some graphic app for editing. GraphicConverter for example features New from clipboard which makes that easy. You can also get this icon from /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericDocumentIcon.icns, but then it is in ICNS format already.

Upvotes: 2

Related Questions