How to 'unregister' a file type / MIME with launch services

I'm working on a document based application in Cocoa, the file is a bundle type (a folder which the Finder shows as a single file much like an application.)

I had everything working perfectly but then I made the mistake of adding a reverse domain name type identifier to my file's type in my info.plist (something I later learned Apple explicitly warn not to do here). Well, this immediately broke my file type, documents from my application only look like folders in the Finder now, so there is no 'open' or 'open with' option on any of them and the data inside is exposed.

Removing the MIME identifier from my plist and rebuilding does not repair the registration of the files type in launch services, not even after explicitly pointing LSRefresh at the build (it is only a debug build).

Please, can any of you terminal gurus tell me how to remove the file type from the Launch Services database? I'm sure that if I can do that then everything will restore when I next launch the app.


Solution 1:

Registering and unregistering apps and document types is done with:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister

To get help with the command simply use the h option.:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -h

In your case I would try to use the unregister option:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -u <path to bundle>

Depending on your app/bundle you may have to prepend a sudo and/or reboot afterwards.


Another step is to completely rebuild the launch services database:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

and/or installing RCDefault.app and trying to remove the MIME/bundle/whatever - which is possible sometimes.