filetype editor "UTI Identifier" = blank

Hi,
I’m on a mac running High Sierra, xojo 2017 R3; I want to open text files with extensions of .adi or .adif

Basic question is in using-file-type-sets it says specifying a “UTI Identifier” is required for mac os; However the only way I’ve found to open these text files with either .adi or .adif extensions is to have the UTI ID be empty… Is it ok to do that? is the UTI ID only required when I go to write the file and set the UTI to be that of my application?

If I have the filetypes setup as:
UTI Identifier:
Conforms To: public.item,public.text,public.data
Extensions: adi;adif
OS Types: ADIF
UTI Type: imported

Then I can do
aFile = GetOpenFolderItem( FileTypes1.ADIFs )

and I can open an .adi file.
However the docs says UTI Identifier is required… If I specify a custom one, then I cannot open any adi files, since they dont have my custom string in there…

doing mdimport -d2
I can see that the kMDItemContentType is set to the UTI ID of the program that created it… eg:
kMDItemContentType = “com.foobar.document.adiffile”;
kMDItemContentTypeTree = (
“public.item”,
“com.foobar.document.adiffile”,
“public.data”
);

The only way I’ve found to be able to open a file configured as above is it specify my UTI ID as “com.foobar.document.adiffile”
However if I install another program which then associates with .adi files, I’m assuming the kMDItemContentType would change and I’d be in the same position… Similarly if I then write a .adi file from my app using a custom UTI, I wouldnt be able to open unless the UTI ID matched…

So I’m confused about what the “right” thing to do it. I’ve read several of the forum posts but I’m still confused about this…
Thanks
-jim

You don’t specify a custom UTI if you are importing someone else’s files. You would put what’s listed in kMDItemContentType.

Now, if your application needs to write these files and you want them to have a custom icon, you could say that it conforms to what’s in kMDItemContentType, mark it as exported and give it a custom UTI.

Unless your Finder settings are (something like) Preview instead of Icon (in the Finder: View --> Show View Options).

If set, you will get the default (TXT) icon instead of the custom one.

[quote=369260:@Emile Schwarz]Unless your Finder settings are (something like) Preview instead of Icon (in the Finder: View --> Show View Options).

If set, you will get the default (TXT) icon instead of the custom one.[/quote]
That’s only true if the file type conforms to the “public.text” UTI.

If the file has a content type tree like this, can I leave the UTI ID blank and just specify the conforms to: as this list on import?
kMDItemContentTypeTree = (
“public.item”,
“com.foobar.document.adiffile”,
“public.data”
);

[quote=369268:@Jim McHale]If the file has a content type tree like this, can I leave the UTI ID blank and just specify the conforms to: as this list on import?
kMDItemContentTypeTree = (
“public.item”,
“com.foobar.document.adiffile”,
“public.data”
);[/quote]
That should be fine. It’s unfortunate that they used a bogus UTI though. I seriously doubt that com.foobar is a valid prefix, but the fact that they inherit public.item and public.data, you’ll still be able to open them.

Thanks Greg; In my example I see several apps that can manipulate these files, each with their own custom uti, but also having standard things like public.text, public.data… since they are at their core just text (or xml) files…

I think the intent of the custom uti was so if one double clicked on the file icon it would open the app… which is what you pointed out above.
-jim