I have developed a Mac application using Qt 5.3.2. This application handles files with specific extension (lets say .xyz
).
I have created an icon file named XYZ.icns and added it to my app bundle Resource folder (MyApp.app/Contents/Resources/XYZ.icns
).
I have also modified the bundle's Info.plist file in order to set the file association. I have added this entry:
<key>CFBundleDocumentTypes</key>
<array>
<!-- Registered file accociation -->
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeName</key>
<string>XYZ</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>xyz</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>XYZ</string>
</dict>
<array>
The result: the file association worked (double clicking on the file does open my application) however, the icon has not been replaced (still displaying the blank document icon).
Is there something that I missed? I looked at other applications for examples and there does not seem to be anything more than what I did.
EDIT: I did some more tests. I dumped the Launch service data with this command:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -dump
In the result, I can find claims on file the file type including the icon information:
...
--------------------------------------------------------------------------------
Container mount state: mounted
bundle id: 105396
...
path: /Applications/MyApp.app
name: MyApp
...
--------------------------------------------------------
claim id: 27628
name: XYZ
rank: Default
reqCaps:
roles: Editor
flags: relative-icon-path doc-type
icon: Contents/Resources/XYZ.icns
bindings: .xyz
--------------------------------------------------------------------------------
...
EDIT2: After some time, it finally got to work on its own. Overnight, there is an OS update that got installed and I also had to shutdown the computer (the Launch Service probably refreshed something on its own). I would update my question to : How to make sure Launch Service refreshes the associated file icons when an application is installed or modified?