I develop a Mac app that saves and loads files of a unique type. The type is properly declared in the info.plist under CFBundleDocumentTypes, listed as LSHandlerRank: Owner and CFBundleTypeRole: Editor. I am releasing a new version of my app and I would like that if users who already have a previous version of my app on their machine install the new version but keep the old version also installed, the new version automatically takes over the file association for this type from the old version of the app. But the default OS behavior seems to be to grant the earliest installed app associated with a file type to be it's permanent owner unless the user manually changes it. I know that the command line tool duti can make association changes, and also the system file com.apple.LaunchServices.plist can be edited, but these don't seem like the best or most reliable way to go about this programmatically from an app. Is there any "right"/Apple-sanctioned way to do what I want?
overriding Mac app file associations via CFBundleDocumentTypes in info.plist
1.6k views Asked by keymap At
1
There are 1 answers
Related Questions in MACOS
- Error installing Nativescript on Mac M2 Sonoma 14.4.1
- macOS - Most secure way of a GUI SUDO_ASKPASS
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Why does Hugo generate different taxonomy-related HTML on different OS's?
- ZSH function parameters conundrum
- how to make read only file/directory in Mac writable
- macOS BigSur - Unable to run bundled php version or brew php 8
- 9 Digit Addresses in Hexadecimal System in MacOS
- MacOS Bash-Script: while read p and echo
- How to make a range for tail rows on a categorized table in Numbers with JXA scripts?
- Cannot build a basic project with curl on Mac (M2) for Raspberry Pi Pico
- How to recover deleted files from create vite react project
- Can't run built SFML project from Xcode template
- React Native - RealmJS - Linker command failed with exit code 1
- How can I manually add a keyboard shortcut to a Shortcut Action Service directly via the system files, without going through the System Prefs GUI?
Related Questions in INFO.PLIST
- iOS Simulator Debug: Launching 'tel' and 'mailto' Schemes Results in Errors
- Deep links in AppleWatch
- Cannot change default Permission String of Expo Plugins (Camera etc.)
- How to use info.plist in Xcode UITest target?
- How to hide a specific active app on OS Sonama (Version 14.1.1)
- Is there a way to code format info.plist file like prettier?
- How to add a value dynamically in Info.Plist file
- How to install Xcode 15.2 on macOS Monterey 12.7.3
- Missing required icon file & Info.plist value error in Xcode
- Asset validation Error while validating app in Xcode (Missing info.plist value etc.)
- Flutter NFC: "The connection to service named com.apple.nfcd.service.corenfc was invalidated from this process"
- Flutter IOS camera permission not working for permission_handler package
- Are Branch.io Test and Live keys considered secrets?
- App rejected Guideline 2.5.4 - Performance - Software Requirements
- The LSUIElement key in Info.plist is being ignored (AvaloniaUI, net7.0-macos)
Related Questions in CFBUNDLEDOCUMENTTYPES
- How can I get my SwiftUI app to show on the IOS Photos Share Sheet?
- File association in iOS
- How to register app to receive screenshots taken by other apps directly
- Adding file icon to custom file type in Xcode
- iOS app custom icons for standard file types like XML
- How to register your app to 'copy to' instead of 'open with' to a certain document type
- I deleted CFBundleDocumentType. But the files are stil connected
- Document type association crashing the App when it's not running
- Where to put the image file for CFBundleTypeIconFiles in iOS?
- Handling two document type
- Cannot add icon to registered document type? Is this a bug?
- Kivy 1.9.1 on El Capitan
- App shown in "Open in.." menu as "Copy to MyApp"
- Cordova: sharing browser URL to my iOS app (Clipper ios share extension)
- overriding Mac app file associations via CFBundleDocumentTypes in info.plist
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
The official, Apple-sanctioned way for an application to set the default application for a file type is probably to use their provided
LSSetDefaultRoleHandlerForContentTypefunction. This function sets the values stored in LaunchServices.Here is the limited official documentation on how to use this API in Objective-C and Swift.
There doesn't appear to be any way to do this via
Info.plist, as the first application get's set as the user preferred application. The user must change their preferred application, which you can facilitate with the above API.