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

1

4

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>
Rigel answered 24/9, 2013 at 14:12 Comment(1)
Your Info.plist does not have the recommended keys CFBundleInfoDictionaryVersion and CFBundleDevelopmentRegion, but I doubt that's your problem, and I don't see anything else wrong.Mortician
M
3

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.)

Mortician answered 24/9, 2013 at 17:59 Comment(1)
lsregister -dump showned the uti with flags 'inactive'. There were also dozens of entries for all the times the app had been installed. A lsregister -kill -r -all local,user cleaned up the entries. The uti became active and icon and double-click now works. Thanks!Rigel

© 2022 - 2024 — McMap. All rights reserved.