So today’s mission: while working on a Mac app, I wanted the correct icon to show up for my documents.
And of course that involved a lot of hair pulling.
Here’s the answer.
(1) Create your document icon. Open the Assets.xcassets, right click on the icon list, and create a new MacOS Generic Icon. (Under “App Icons and Launch Images”.) Create your document icon in the resulting icon, renaming as appropriate. (In my case, I named it “DocIcon.”)
(2) On Xcode 9.4, if you open the project file, select “Info” and show the Document Types, the “Icon” drop down does not show the contents of the Assets catalog for your icon. Xcode lies!
Just type the Assets icon name into the drop-down. You’ll continue to see a question mark. Don’t sweat it.
(3) There is no step 3.
Now of course if you want to allow other apps to play in your background, you can also export a UTI. Notice how I defined an “Identifier” above? Well, if you don’t export a UTI this won’t work; leave “Identifier” as blank.
However, if you want to tell the OS that your file is a type of another file–like, for example, your file can be opened as a text file, then define your UTI identifier (using the com.blahblahblah style for UTIs), and add an exported UTI:
This basically says “hey, MacOS, that UTI type “com.chaosinmotion.Kythera.gearfile” I told you about? Yeah, it’s also a “public.text” text file.
And you can also import UTI types; that basically tells the system “hey, I can open public.text files!” But that’s beyond the scope of stuff I care about right now.