xcodemacosplistdocument

How to make a MacOS document-based app recognize a ".txt" file in Open dialog


In XCode 13.3, I create a brand new Document-based MacOS application, called OpenTextDoc. It immediately runs, and when I choose the app's Open... menu command, the Open File dialog shows all files with extension ".txt" as grayed out and unselectable.

After shutting down, and without having changed a single thing anywhere in the code or other parts of the project, I click on the top-level project name in XCode's window, and then on the Info tab on the right editing side, to get at the property list (or some of it?) for the app. There is a disclosure button for a one-item list for Document Types. I click on it, and the following is the display screenshot.

enter image description here

There is a grayed label that says "Click here to add additional document type properties". Clicking on any part of it does nothing, and where "here" is is anyone's guess.

Clicking on the "+" sign below just adds another entry like the one above, and shows another un-clickable label just like above.

At one point while futzing with this, XCode crashed entirely after I clicked on something.

What steps must one accomplish (and where) to enable a completely vanilla, document-based app like this to open a ".txt" file with the Open File dialog, as well as text files using another file extension, say ".text"??


Solution

  • There is a corresponding entry with the same identifier in the Imported Type Identifiers section. Change the identifier in the Document Types and Imported Type Identifiers sections to public.plain-text. Change the extensions in the Imported Type Identifiers section to txt, text.

    Example

    Info.plist:

    Info.plist