File type not recognized by macOS

My app uses the following 2 exported file types:

   <key>UTExportedTypeDeclarations</key>
   <array>
      <dict>
         <key>UTTypeIdentifier</key>
         <string>org.the-meiers.coolterm-Settings</string>
         <key>UTTypeConformsTo</key>
         <array>
            <string>public.text</string>
           <string>public.data</string>
         </array>
         <key>UTTypeDescription</key>
         <string>CoolTerm Connection Settings</string>
         <key>UTTypeIconFile</key>
         <string>Connection.icns</string>
         <key>UTTypeTagSpecification</key>
         <dict>
            <key>public.filename-extension</key>
            <array>
            <string>stc</string>
            </array>
            <key>com.apple.ostype</key>
            <array>
               <string>TEXT</string>
            </array>
         </dict>
      </dict>
      <dict>
         <key>UTTypeIdentifier</key>
         <string>org.the-meiers.coolterm-Session</string>
         <key>UTTypeConformsTo</key>
         <array>
            <string>public.text</string>
           <string>public.data</string>
         </array>
         <key>UTTypeDescription</key>
         <string>CoolTerm Session</string>
         <key>UTTypeIconFile</key>
         <string>Session.icns</string>
         <key>UTTypeTagSpecification</key>
         <dict>
            <key>public.filename-extension</key>
            <array>
            <string>CoolTermSession</string>
            </array>
            <key>com.apple.ostype</key>
            <array>
               <string>TEXT</string>
            </array>
         </dict>
      </dict>
   </array>

The first one (org.the-meiers.coolterm-Settings) recently (not sure when because I didn’t pay attention) stopped working properly while the second one works just fine. What I mean by “not working properly” is that the Finder won’t show it’s icon, and when I use the Open dialog in my app, this file type is grayed out and can’t be selected.

I can’t figure out what the problem is. Any ideas? Any insight will be appreciated.

Did you try another Mac?
This may just be a broken database for your Finder.

You must have a built app or the Finde will forget the settings. Can you show the screenshots from Xojo where you declare your types?

The easiest way to solve those problems is by borrowing the plist of an app where the file type works.

I tried several Macs, and it’s the same problem on each one.

Here is a screenshot:


The “Session” file type works. The “Setting” one doesn’t

What’s interesting is that if I change the extension from .stc to something else, it makes the “Setting” file type work.

I also just checked with a friend who uses my app on his Mac, and he confirmed the same issue.

The extension .stc may be in conflict with other apps extensions - in a quick search i found that OpenOffice uses .stc als extension for its “Calc Spreadsheet Template Format”…

Hmm, interesting. The fact that changing .stc to something else makes it work seems to to indicate there is indeed something about this extension that may be the problem.
I’ve been using this extension for about 20 years, and haven’t come across any conflicts until now. I also don’t have OpenOffice on any of my machines. No idea what it may be colliding with.

If I remember correctly, Apple used to require registration of file extensions to prevent double use. Whether that’s still the case today: I have no idea.

But maybe this is a point you can start your search…

I had to do one of the olden 4 letter codes like 20 to 25 years ago by snail mail. But extensions don’t need to be registered.

1 Like

Hey hi, please verify that the icon file specified in UTTypeIconFile Connection.icns exist and is accessible and check that the file extensions specified in UTTypeTagSpecification match the file type stc.

I’d say you took a risk by defining an extension of only 3 characters. The Windows world is already filled with those, which can easily be ported to MacOS.
I usually use words (or longer extensions) to be [almost] safe.

Thanks!

The icons exists, and the public.filename-extension key in UTTypeTagSpecification in the plist file (see first post) does have a value of stc.

Thanks, I’ll give that a shot.

Yeah, I know. I introduced the ability to save sessions only a few years ago, and I’m using .CoolTermSession as the file extension. That works without a problem.

Just for giggles, I made a build with .CoolTermSettings instead of .stc as the extension for settings files, and that works totally fine. So everything seems to be pointing at .stc being the culprit. That’s a bummer, because I really don’t want to change the file extension after all this time.

2 Likes

It would seem that, after looking for a little bit, I also found that stc is used by OpenOffice:

I do wonder whether that is the root cause for this…

Well, it looks like I could have save myself a lot of googling and wondering if I had taken a closer look at “Get Info” of one of my settings files:

image

I have never installed OpenOffice on either of my Macs, so this must be something that is baked into macOS somewhere. Even one of my older ones, running Big Sur, thinks this is a OpenOffice file now. And I know for a fact this wasn’t the case before. This was my development machine before I upgraded my hardware because my development machine couldn’t be upgraded to Monterey. One of the service upgrades for Big Sur must have updated a database on the machine.

2 Likes

That’s fantastic.

That still shouldn’t prevent your app from creating and opening these files, but I am going to make a suggestion…

UTI is a hierarchy system even though it’s not really exposed that way in Xojo. In your case the types have two levels:

org.the-meyers.coolterm-session
public.text

What you’re telling the system here is that your file type can also be opened by any app that can also open plain text.

This information is saved with the files when they are written by your app and is why you can have two apps with the same extension on the same machine.

Ultimately You could get the OpenOffice type to open in your app by simply dragging one of those files into the FileTypes editor. The IDE will ask the OS for all of the pieces and then you can just set the role to editor.

Hint: if you want to see all of the metadata associated with something on disk, just go to a terminal and type

mdls <path to file>