editing info.plist file to get file associations *.xyz
lazarus / 33-macOS - Mac OS X
----------------------------------------------------------------------
Martin V · 2011-12-05 10:45
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/C
onceptual/understanding_utis/understand_utis_declare/understand_utis_d
eclare.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 · 2011-12-05 13:08
this: http://web.me.com/macpgmr/ObjP/MacXPlatform_Part8.html#DropFiles
----------------------------------------------------------------------
ludob · 2011-12-05 13:12
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 CFBundleDocumentTypes
- replace
Code: [Select] CFBundleTypeRole
Viewer
CFBundleTypeExtensions
*
with
Code: [Select] CFBundleTypeRole
Editor
CFBundleTypeExtensions
tst
LSIsAppleDefaultForType
- 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] CFBundleIconFile
myapplication.icns
just after the previous lines.