Recent

Author Topic: editing info.plist file to get file associations *.xyz  (Read 11945 times)

Martin V

  • Full Member
  • ***
  • Posts: 139
editing info.plist file to get file associations *.xyz
« on: December 05, 2011, 11:45:53 am »
Hello,

does anyone has a step-by-step explanation how to edit the plist.file (and/or other files) to get a file association *.xyz for my own program so the user can double click to the data file and my program gets started?

I found this documentation from Apple:

http://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/understanding_utis/understand_utis_declare/understand_utis_declare.html

I managed to add the program icon file, but not the file assocation. It seems that there are two steps: Defining a new data type *.xyz and then associating my application bundle to this new data type. I even didn't understand if the file type definition is part of the info.plist file or is located elsewhere. There also can be a definition.plist file in the application bundle, no idea what this file is for.


Shebuka

  • Sr. Member
  • ****
  • Posts: 427

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: editing info.plist file to get file associations *.xyz
« Reply #2 on: December 05, 2011, 02:12:16 pm »
If file association is all you need then the solution is quite simple.

Assume you project is called project1 and the file you want to open has extension .tst.
- edit project1.app/Contents/Info.plist
- look for <key>CFBundleDocumentTypes</key>
- replace

Code: [Select]
<key>CFBundleTypeRole</key>         
                        <string>Viewer</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>

with

Code: [Select]
<key>CFBundleTypeRole</key>         
                        <string>Editor</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>tst</string>
</array>
<key>LSIsAppleDefaultForType</key>   <true/>
- save the file
- move project1.app with Finder into another directory (and move it back if you like).  Launching project1 isn't enough to register Info.plist with Launch Services. Moving the application bundle in Finder does.

If you just want to open .tst files and not save them, you can leave CFBundleTypeRole Viewer.

If you want Finder to display your icon for your file extension then add also
Code: [Select]
                        <key>CFBundleIconFile</key>  <string>myapplication.icns</string>
just after the previous lines.

 

TinyPortal © 2005-2018