CFBundleTypeIconFile指定文件扩展名不显示的图标 [英] CFBundleTypeIconFile Icon not showing for given file extension

查看:417
本文介绍了CFBundleTypeIconFile指定文件扩展名不显示的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Info.plist为我的应用程序,问题是文件我保存与扩展myapp似乎并没有拾起我的MyApp图标,我已经从一个图标集创建(应用程序正确使用图标)所以猜测在plist有错误。

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.

在这种情况下,文档是从一组基于NSCoder的类保存的。点击这些文件也会打开我的应用程序并加载文件正确,所以困惑我缺少的图标来显示在文件....

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>


推荐答案

结果系统必须缓存了一个旧的副本plist当我最初创建我的应用程序。所有需要的是重建启动服务数据库。

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.

我使用lsregister命令,如下所示:

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/

重新运行应用程序,bingo文档现在有相关的图标。

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

这篇关于CFBundleTypeIconFile指定文件扩展名不显示的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆