In a four yeras old application (used every day), I used a custom sqlite db file extention (cdb).
I noticed recently a strange behavior: the application refuse to open a .cdb file when I drag it on the application icon.
As a test, minutes ago, I duplicated a .cdb file, changed its file extension to .sqlite and my application reacted to the drop !!!
How can it be so: .sqlite is not set in the application.
If you want to control this, theres three things that you need:
The UTI for your file needs to be unique. Use your app identifier + .cdb, and inherited from public.database if you want other database editors to continue taking it.
The file type must be marked as Exported because its something that your app creates. Dont do this with just public.database or youll screw up other apps that take that.
Make sure your app accepts this type by adding it in the macOS build target. Youll want to set the role to Editor.
the project started with Real Studio (probably a 2012 version).
the project actually runs on 2015r1.
The .cdb custom file is defined as follows:
File Type Set Name: FT_DB
Display Name: Base de donnes Caritas (cdb)
Object Name CaritasCDB
MacType: SQL
MacCreator: <empty>
Extensions: .cdb
UTIs: public.database
Icon: filed with a custom icon
In the BUILD SETTINGS for OS X, I have (between others):
Creator Code: ecdb
File Types (Choose button) where I get a sheet window that display here (five entries)
I have the FT_DB File Type Set defined as Editor (as FT_DB.CaritasCDB). I also have a defined TEXT file (as Editor).
The .txt files are accepted if I try to drop one on my App icon. Same kind of definition.
I just tried to drop an xml file above my app icon (despite its not Editor status [certainly set to none]). It is certainly the TEXT defined FTS that is responsible for this behavior).
It may be important to note: I use one File Type Set for each defined file kind. So, as far as I can see, I have in a folder five defined File Type Sets (for DB, Folder, JSON, TXT and XML, not in this alphabetical order).
Is the appearance order of the the File Type Sets meaningful ?
I certainly had troubles with File Type Sets to do that (or I do not wanted to get troubles using a single File Type Sets with all my five defined types).
Another question: is theres a document (I do not found yet) that highlight how to set an application as drop friendly ?
We fixed a few bugs regarding UTIs and modern versions of macOS last summer (either 2016r2 or 2016r3), so its possible that you are running into something that was fixed since 2015r1.
I can also tell you that macOS tends to use the UTI definitions from the application with the highest version number attached… and if there are more than one on your machine, its usually the first one that it encountered. What Im saying is that if youre testing and the version number is 2.0.1.0 and you dont increase that number in some way from build to build, you may not see the effect of your changes when you rebuild. This is a really good use of the auto increment feature of the non-release number.