Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register new OS X file type by extension & associate with Cocoa app

OK, so here's the deal :

  • I've got a new app which I want to associate with a new file type - let's say .xyz
  • .xyz files - if that matters at all - is a Package file.

Now, here's how the filetype-specific portion of my info.plist looks like :

CFBundleDocumentTypes = (
        {   
            CFBundleTypeExtensions = ( "xyz" );
            CFBundleTypeIconFile = "xyz-icon";
            CFBundleTypeName = "XYZ file";
            CFBundleTypeRole = "Viewer";
            LSTypeIsPackage = "1";
        }
    );

However, the .xyz package files are still shown as folders and NOT as a single file ("package"). What am I doing wrong?


HINT : I've managed to do that in the past, but I simply cannot remember if I'm missing something. Perhaps the system has to be restarted? I have no idea...

like image 845
Dr.Kameleon Avatar asked Nov 14 '25 22:11

Dr.Kameleon


1 Answers

If you found this stackoverflow page because LSTypeIsPackage isn't working for you, it might be because you're using LSItemContentTypes to declare your document type. The use of LSItemContentTypes makes the system ignore LSTypeIsPackage (which isn't the case in this stackoverflow question).

If you're using LSItemContentTypes, you need to make your exported type conform to com.apple.package. Example:

CFBundleDocumentTypes
  LSItemContentTypes
    Item 0 = com.example.xyz
  CFBundleTypeExtensions
    Item 0 = xyz
  CFBundleTypeRole = Editor
  etc.

UTExportedTypeDeclarations
  Item 0
    UTTypeIdentifier = com.example.xyz
    UTTypeConformsTo
      Item 0 = public.data // or whatever
      Item 1 = com.apple.package          <-------------
    UTTypeDescription = XYZ Document
    etc.
like image 60
rob mayoff Avatar answered Nov 18 '25 22:11

rob mayoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!