Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CFBundleTypeIconFile Icon not showing for given file extension

Tags:

macos

cocoa

I have the following Info.plist for my application, the problem is files i save with the extension myapp do not seem to pick up on my MyApp icon which i have created from an icon set (application correctly uses icon) so guessing there is something wrong in the plist.

I am assuming if I got this working when running my application at some point documents that I have save will suddenly show with the given icon.

Incase this matters, the document is saved from a set of NSCoder based classes. Clicking these documents also opens my application and loads the file correctly, so confused what I am missing to get Icon to show on the files....

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>myapp</string>
            </array>
            <key>CFBundleTypeIconFile</key>
            <string>MyApp</string>
            <key>CFBundleTypeOSTypes</key>
            <array>
                <string>ASWM</string>
            </array>
            <key>CFBundleTypeName</key>
            <string>MyApp project file</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
        </dict>
    </array>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIconFile</key>
    <string>MyApp</string>
    <key>CFBundleIdentifier</key>
    <string>com.workmonkeys.${PRODUCT_NAME:rfc1034identifier}</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>ASWM</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSApplicationCategoryType</key>
    <string>public.app-category.developer-tools</string>
    <key>LSMinimumSystemVersion</key>
    <string>${MACOSX_DEPLOYMENT_TARGET}</string>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright © 2012 Me. All rights reserved.</string>
    <key>NSMainNibFile</key>
    <string>MainMenu</string>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
</dict>
</plist>
like image 244
Equinox2000 Avatar asked Sep 17 '12 19:09

Equinox2000


1 Answers

Turns out the system must have cached a old copy of the plist when I initially created my application. All that was needed was to rebuild the launch services database.

I used the lsregister command as documented here...

http://www.tuaw.com/2009/06/11/terminal-tips-rebuild-your-launch-services-database-to-clean-up/

Rerun the application and bingo the documents now have the respective icon associated.

like image 143
Equinox2000 Avatar answered Dec 09 '22 00:12

Equinox2000