AppKit Document based app, cannot open document

Hello,
I am working on a Mac OS app to manage .abc files; these are plain text files (you can open them with TextEdit) that can be used to build music scores.

I cannot set document the and UTI properly in my project. When I tap +O , in the open dialog, .abc files are greyed out, so cannot choose them.

I am not the owner/inventor of the .abc format, so I am setting an exported UTI. Here are details from my plist.

Code Block
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconSystemGenerated</key>
<integer>1</integer>
<key>CFBundleTypeName</key>
<string>ABC Music File</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>com.davidebenini.abc</string>
</array>
<key>NSDocumentClass</key>
<string>$(PRODUCT_MODULE_NAME).Document</string>
</dict>
</array>


And:

Code Block
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>ABC Music File</string>
<key>UTTypeIcons</key>
<dict/>
<key>UTTypeIdentifier</key>
<string>com.davidebenini.abc</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>abc</string>
<string>ABC</string>
</array>
</dict>
</dict>
</array>


I have been tweaking these settings a bit; I also tried using Exported UTI, but that was also to no avail.

Do you have any suggestions?
Thanks in advance,
Davide
Answered by nuutsss in 641814022
Ok, maybe I am getting somewhere.
I used a terminal command to get the actual UTI of my tunebook.abc file. I got this output:

Code Block
kMDItemContentType     = "public.alembic"
kMDItemContentTypeTree = (
    "public.alembic",
    "public.3d-content",
    "public.content",
    "public.data",
    "public.item"
)
kMDItemKind            = "Scena 3D Alembic"

So it looks like there is a public UTI for the .abc extension, but it is completely unrelated.
That is, the .abc extension is used both for abc music scores and for Alembic 3d scene.

Now, what is the most correct way to solve this ambiguity? That is, to tell Mac OS that abc files may be open ALSO with my app?



If you are not the creator of the abc file type, you should not be creating the UTI com.davidebenini.abc for the file type. An existing file type should have its own UTI already. You should create a new UTI like com.davidebenini.abc only for file types that you create.

If the abc file format is a plain text file format, shouldn't it conform to a plain text UTI, public.plain-text, instead of public.data?

Is your NSDocument subclass called Document?

Those are the only possible things I can see wrong with your info.plist file.
Hi,
thanks for your feedback.

About public.plain-text, I tried that already, no luck, so I put public.data just to try bit out.

As a matter of fact I meant to use "com.abcnotation" as an identifier in the (eventual) release version, I put my name-surname just as a placeholder for testing purposes.
I could not find a public UTI for ABC defined anywhere, I believe .abc has no public UTI.

abc files are plain text files, but have usually an .abc extension, so

I guess what I am aiming to is having the file selector let you choose both .txt and .abc files; I started with .abc because this seems the most critical part to tackle.

Anyway, my document class is called Document indeed.

One question: if UTI and document types are correctly defined, am I supposed to see .abc files as selectable in the open dialog? Should I look somewhere else ( don't know, maybe a delegate method or something similar...) ?

Cheers,
Davide

Accepted Answer
Ok, maybe I am getting somewhere.
I used a terminal command to get the actual UTI of my tunebook.abc file. I got this output:

Code Block
kMDItemContentType     = "public.alembic"
kMDItemContentTypeTree = (
    "public.alembic",
    "public.3d-content",
    "public.content",
    "public.data",
    "public.item"
)
kMDItemKind            = "Scena 3D Alembic"

So it looks like there is a public UTI for the .abc extension, but it is completely unrelated.
That is, the .abc extension is used both for abc music scores and for Alembic 3d scene.

Now, what is the most correct way to solve this ambiguity? That is, to tell Mac OS that abc files may be open ALSO with my app?



AppKit Document based app, cannot open document
 
 
Q