On Sep 10, 2018, at 23:05:21, Steve Mills via Groups.Io <sjmills@...> wrote:
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>
Turns out that the OS is getting confused because there is another app that declares UTIs for files with the extensions my app can open. I've tried moving the UTIs from exported to imported, since my app does not create files of those types, it's only a viewer. I tried deleting the UTIs and leaving only the document types, which made my app unable to open the files from Open dialog or Finder. Deleting the LSItemContentTypes from each document type allows my app to *know* it can open the files again, but I then need to find another way to identify file types, since before I was using the UTI of the file.
How is this supposed to work for extensions that are widely used but aren't official like cbr and cbz?
--
Steve Mills
Drummer, Mac geek