Override System UTI

For the application that I am developing, we have developed an HTML-based file format so that even users who do not have our application can view the document using a web browser.

However, for users who have an application, we want to use it to open these files. We decided to use the .shtml extension, which by default is open by the browser for most OS and is not used widely.

Now we are having difficulty getting MacOS to understand that our .shtml files are different from regular .html files and should be open with our application. The problem is that MacOS is already registering .shtml files as "public.html". Even if I define UTI with UTTypeIdentifier "com.example.shtml" and UTTypeTagSpecification public.filename-extension from "shtml", the system always detects .shtml files as "public.html" and not "com.example.shtml", although I set UTTypeConformsTo to 'public.html' ...

The heuristic documentation used by the OS to detect system UTIs is at least limited, so I cannot find how to modify the file so that it is not detected as public.html. Any help or directions in the right direction is appreciated. Thanks!

+7
macos
source share
2 answers

Unfortunately, this is not possible, since macOS added SIP, which prevents any changes to the system defined by UTI without rebooting when SIP is disabled. I suggest setting a default for your application for public.html and redirecting any file that does not meet your default browser requirements, for example.

+1
source share

All Articles