Frederik Theisen
Frederik Theisen

Reputation: 35

How can I make custom icons appear for document types associated with my macOS app in the Finder?

I have successfully created UTIs and the Finder is able to identify that the files belong to my application and that they are specific types (such as ITC Data File). However, I am unable to make the OS use the custom icons I have specified in my property list file in Xcode.

Here is the relevant portion of my plist file:

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>itc</string>
                <string>vpitc</string>
                <string>ITC</string>
            </array>
            <key>CFBundleTypeIconFile</key>
            <string>DataFileBackground</string>
            <key>CFBundleTypeIconSystemGenerated</key>
            <integer>0</integer>
            <key>CFBundleTypeName</key>
            <string>ITC Data File</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Default</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.itcdatafile</string>
            </array>
            <key>NSDocumentClass</key>
            <string></string>
        </dict>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>ftitc</string>
                <string>FTITC</string>
            </array>
            <key>CFBundleTypeIconFile</key>
            <string>ProjectFileIcon</string>
            <key>CFBundleTypeIconSystemGenerated</key>
            <integer>0</integer>
            <key>CFBundleTypeName</key>
            <string>FT-ITC Project File</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Default</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.ftitcproject</string>
            </array>
            <key>NSDocumentClass</key>
            <string></string>
        </dict>
    </array>

I previously managed to get the Finder to show a custom test icon, but I am unsure how I did it and am unable to reproduce it. The icons are defined in the 'Assets' as 'macOS generic icon': Screenshot of Assets folder in project

How can I get custom icons for my associated files? And does the change (if successful) take time for the OS to update?

Thanks.

Upvotes: 0

Views: 87

Answers (1)

Frederik Theisen
Frederik Theisen

Reputation: 35

Issue might have been related to the system cacheing the icons. Right clicking the file and clicking 'view info' resulted in the system updating the icon.

When I update the icon .png file, I also need to do this to get the system to use the new image as icon.

Upvotes: 0

Related Questions