MacOS – How to make an app as default opener for particular file extension

gatekeepermacosplistpython

I am making an app in python named cipherc on mac osx 10.9 This app opens a file type of extension “.secure

Now, in local system, for already present .secure file, its default file opener is some different xyz app. So, how can I make my app cipherc as default file opener for all .secure file extension present in system, as soon as I installs cipherc app.

My info.plist is:

<?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>English</string>
    <key>CFBundleDisplayName</key>
    <string>cipherc</string>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeOSTypes</key>
            <array>
                <string>****</string>
                <string>fold</string>
                <string>disk</string>
            </array>    
            <key>CFBundleTypeName</key>
            <string>secure</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
        </dict>
    </array>
    <key>CFBundleExecutable</key>
    <string>cipherc</string>
    <key>CFBundleIconFile</key>
    <string>cc.icns</string>
    <key>CFBundleIdentifier</key>
    <string>com.cipherc.macapp.cipherc</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>cipherc</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>0.0.0</string>
    <key>LSBackgroundOnly</key>
    <true/>
    <key>LSHasLocalizedDisplayName</key>
    <false/>
    <key>NSAppleScriptEnabled</key>
    <false/>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright not specified</string>
    <key>NSMainNibFile</key>
    <string>MainMenu</string>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
    <key>PyMainFileNames</key>
    <array>
        <string>__boot__</string>
    </array>
    <key>PyOptions</key>
    <dict>
        <key>alias</key>
        <false/>
        <key>argv_emulation</key>
        <true/>
        <key>emulate_shell_environment</key>
        <false/>
        <key>no_chdir</key>
        <false/>
        <key>prefer_ppc</key>
        <false/>
        <key>site_packages</key>
        <false/>
        <key>use_faulthandler</key>
        <false/>
        <key>use_pythonpath</key>
        <false/>
        <key>verbose</key>
        <false/>
    </dict>
    <key>PyResourcePackages</key>
    <array>
    </array>
    <key>PyRuntimeLocations</key>
    <array>
        <string>@executable_path/../Frameworks/Python.framework/Versions/2.7/Python</string>
        <string>/System/Library/Frameworks/Python.framework/Versions/2.7/Python</string>
    </array>
    <key>PythonInfoDict</key>
    <dict>
        <key>PythonExecutable</key>
        <string>/usr/bin/python</string>
        <key>PythonLongVersion</key>
        <string>2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]</string>
        <key>PythonShortVersion</key>
        <string>2.7</string>
        <key>py2app</key>
        <dict>
            <key>alias</key>
            <false/>
            <key>template</key>
            <string>app</string>
            <key>version</key>
            <string>0.8</string>
        </dict>
    </dict>
</dict>
</plist>

Best Answer

You have to do it manually, because Mavericks won't change the default app automatically, if there is already an app that can open .secure-files.

Follow these instructions and choose your script as app.

  1. Find a file with an extension you want to change the defaults to. Right click on the file to see a menu, and select “Get Info”.

  2. A window appears with the file’s information, see the section called “Open with”

  3. It will display the current application used for this file, use the dropdown box to select you new application. You have to use the “Other” selection to browse for it.

  4. Click on the “Change All” button to apply the change to all files ending with the same file extension.

  5. That’s all.