Document types not working


Steve Mills
 

I'm sure I had this working earlier in development of the macOS version of my app, but custom file types are no longer openable by my app. I've declared exported UTIs for cbr and cbz extensions and added them as document types where each type has a Role of Viewer and a Handler rank of Owner.

There are at least 2 other apps on my machine that also claims both extensions. Files of either type are showing as being owned by one of them, even though I've told the system to open all files of that type with my app, so it's the default app for those types.

Note that there's also an iOS version of this app which uses a different bundle ID. It also claims these 2 types using its own app-specific UTIs. So builds of both apps exist on my Mac. Hopefully iOS app builds can not affect how macOS sees and registers file types.

This is spitting out nil:

[NSDocumentController.sharedDocumentController documentClassForType:@"Comic Book RAR"];

Here's one of the exported UTIs:

<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.archive</string>
</array>
<key>UTTypeDescription</key>
<string>Comic Book RAR</string>
<key>UTTypeIdentifier</key>
<string>com.ArmpitStudios.BoxOfFun.cbr</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>cbr</string>
</array>
<key>public.mime-type</key>
<array>
<string>application/x-cbr</string>
</array>
</dict>
</dict>

And here's the corresponding document type:

<dict>
<key>CFBundleTypeIconFile</key>
<array/>
<key>CFBundleTypeName</key>
<string>Comic Book RAR</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.ArmpitStudios.BoxOfFun.cbr</string>
</array>
<key>NSDocumentClass</key>
<string>Document</string>
</dict>

Any ideas? This is driving me batty.

--
Steve Mills
Drummer, Mac geek

Join cocoa@apple-dev.groups.io to automatically receive all group messages.