Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override system-defined UTI

Tags:

macos

For an application I'm developing, we developed a file format based on HTML, so that even users who don't have our app can preview the document using a web-browser.

However, for users who do have the app, we want to use it to open these files. We settled on using the '.shtml' extension, which is opened by the browser by default on most OSs, and not used widely.

We are now running into trouble to make MacOS understand that our .shtml files are different than regular .html files, and should be opened with our app. The problem is that MacOS already registers .shtml files as "public.html". Even if I define an UTI with UTTypeIdentifier "com.example.shtml", and UTTypeTagSpecification's public.filename-extension of 'shtml', the system always detects .shtml files as 'public.html' and not 'com.example.shtml', even though I set UTTypeConformsTo to 'public.html'...

The documentation about the heuristics the OS uses to detect system-defined UTIs is scarce, to say the least, so I cannot find how to change my file to not be detected as public.html. Any help, or pointers in the right direction is welcome. Thanks!

like image 770
arantes Avatar asked Aug 28 '17 14:08

arantes


2 Answers

the file associations works based on mime type, UTI definations. hope these links help you https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_declare/understand_utis_declare.html

like image 125
RamiReddy P Avatar answered Oct 12 '22 02:10

RamiReddy P


Unfortunately this is impossible since macOS added the SIP which prevents any modifications of system defined UTI without rebooting with SIP deactivated. What I suggest would be to set your app as default for public.html and redirect any file which doesn't match your requirements to the default browser for example.

like image 28
Timothée Rebours Avatar answered Oct 12 '22 02:10

Timothée Rebours