Mac File association not working. Why or how to debug?

假如想象 提交于 2019-12-09 00:10:05

问题


I have the following Info.plist which I am attempting to associate .mybin files with the applcation. However after installing the .mybin files do not have the icon, the description or the association (when viewing with Get Info). I'm completely new to OSX development and I inherited the packaging of the application so I have no idea how to debug problems. The app is packaged to a .app using productbuild if that makes any difference.

I have compared my info.plist against several other applications and the only difference I can see is many include deprecated keys such as CFBundleTypeExtensions. Since I only need to support 10.6 and greater I don't believe I need this and LSItemContentTypes should be enough. From what I understand the 'com.me.myapp.mybin' of LSItemContentTypes is the link to the exported UTI of the same name.

I have tried manually associating the .mybin file with the application, but that fails when I double-click saying the app does not handle that type of file.

Can anyone tell we what is wrong with this info.plist or what to do investigate?

Thanks.

<plist version="1.0">
<dict>
    <key>CFBundleIconFile</key>
    <string>MyApp.icns</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleGetInfoString</key>
    <string>My Application version 1.0, Copyright © 2013.</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleExecutable</key>
    <string>My Application</string>
    <key>CFBundleName</key>
    <string>My Application</string>
    <key>LSMinimumSystemVersion</key>
    <string>10.6</string>
    <key>CFBundleIdentifier</key>
    <string>com.me.myapp</string>
    <key>CFBundleDisplayName</key>
    <string>My Application</string>
    <key>CFBundleVersion</key>
    <string>1.0.0</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.0</string>
    <key>LSMultipleInstancesProhibited</key>
    <true/>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFile</key>
            <string>MyApp</string>
            <key>CFBundleTypeName</key>
            <string>My Application binary</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.me.myapp.mybin</string>
            </array>
            <key>LSHandlerRank</key>
            <string>Owner</string>
        </dict>
    </array>
    <key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.data</string>
            </array>
            <key>UTTypeDescription</key>
            <string>My Application binary</string>
            <key>UTTypeIconFile</key>
            <string>MyApp.icns</string>
            <key>UTTypeIdentifier</key>
            <string>com.me.myapp.mybin</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <string>mybin</string>
                <key>public.mime-type</key>
                <string>application/vnd.me-app.binary</string>
            </dict>
        </dict>
    </array>
</dict>
</plist>

回答1:


You could investigate using the lsregister command:

alias lsregister='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister'
lsregister -lint -f /path/to/your.app

(I'm using Lion. On a different version of the Mac OS, it's possible that the path to lsregister is different.)



来源:https://stackoverflow.com/questions/18984025/mac-file-association-not-working-why-or-how-to-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!