Swiftpack.co - Lord-Kamina/SwiftDefaultApps as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Lord-Kamina.
Lord-Kamina/SwiftDefaultApps v2.0.1
Replacement for RCDefaultApps, written in Swift.
⭐️ 1,188
🕓 3 weeks ago
.package(url: "https://github.com/Lord-Kamina/SwiftDefaultApps.git", from: "v2.0.1")


This Preference pane is chiefly intended to be a modern replacement for the amazing RCDefaultApp developed way back when by Carl Lindberg, which stopped working in 10.12 due to deprecation of ObjC Garbage collection. Additionally, I guess it was a good way to teach myself Swift.

Feel free to contribute, comment or report issues at https://github.com/Lord-Kamina/SwiftDefaultApps.

Installing & Uninstalling

Download latest release from https://github.com/Lord-Kamina/SwiftDefaultApps/releases
To install, double click on the .prefpane, and you will be prompted to install it.
To uninstall, simply Ctrl+Click on the Prefpane icon and remove it, or move the .prefpane file to the Trash.

Installting with brew


brew install swiftdefaultappsprefpane

then use Spotlight to open the `SwiftDefaultApps.prefpane`. It will open the system preferences and you find the app on the bottom of the icons.

:warning: The **Do Nothing** dummy app needs to be launched before to use it in the pref pane. For this, open a terminal and run the 2 following commands:

# If, when you installed the Preferences Pane, you only installed it for the current user,
# replace /Library with ~/Library in the two commands below

# Remove quanrantine flag
xattr -r -d com.apple.quarantine /Library/PreferencePanes/SwiftDefaultApps.prefPane/Contents/Resources/ThisAppDoesNothing.app
# Open the app
open /Library/PreferencePanes/SwiftDefaultApps.prefPane/Contents/Resources/ThisAppDoesNothing.app

After these 2 steps, the Do Nothing app should work when you pick it up.

Usage Notes

This Preference pane will let you view and change default application associations for basically any URI Scheme and/or filetype in macOS. The user-interface should be pretty self-explanatory; but, there are some things that might require an explanation:

  • Selecting any URI Scheme or File type (always represented by a UTI), will give you a list of all valid applications for each LaunchServices role. This data is generated by LaunchServices itself.
    • There's two additional options:
      • One of them is "Do Nothing", what this does is register the item to be handled by a dummy application which basically does nothing. Its only function is being able to open any URI Scheme or UTI whatsoever, printing a line to the console (specifying whatever it was that launched it) and immediately quitting. By default this application should be located in the Resources folder inside the prefpane bundle; SwiftDefaultApps will, however, also look for it in the directory it is itself located in (for the CLI version) and every Applicationsfolder in the computer.
      • The second is "Other...", which obviously will allow you to select an application not in the list; with a caveat. In recent versions of macOS, the LaunchServices have become quite a bit smarter under the hood than they used to be. In practice, what this means is that although you can choose any application to handle anything, only valid associations will be preserved, as the LaunchServices is permanently looking for invalid or stale associations and removing them.
    • One final note: In the URI Schemes tab, you have the option of adding a custom URI Scheme (Removing them on demand is neither possible nor necessary, due to the same thing explained above). This options is provided for completeness' sake; you should virtually never need to use it, since Launch Services should be able to properly detect any valid URL Handlers. As a further cautionary note: If you add a custom URI Scheme when it is not needed, you may not be able to remove it except by uninstalling and reinstalling SwiftDefaultApps. Why? Because new schemes are by default associated to *"Do Nothing", which means Launch Services will always find a valid handler as long as SwiftDefaultApps is installed.

How to Find Out File UTI

Run in your terminal the following command (replace my_song.mp3 by your file):

mdls -name kMDItemContentType -name kMDItemContentTypeTree -name kMDItemKind my_song.mp3

Acknowledgments & Attributions

Current Version

- Version: 2.0.1
- Date: 2019-07-26

Known Issues


  • Localizations

Release Notes

[2.0.1] - 2019-07-26

  • Fixed

    • CLI: Crash when displaying the results for setHandler with shortcuts such as internet, browser, email, etc.

[2.0.0] - 2019-06-12

  • Added

    • Signed prefpane, CLI and Dummy apps.
    • Both the prefpane and the CLI version will now automatically try to locate ThisAppDoesNothing.app if it does not appear registered with launch services.
  • Changed

    • SwiftCLI is now built and linked as a static library instead of a framework.
    • Updated to Swift 5
    • The content array is now populated by overriding didSelect() instead of relying on an arbitrary sleep timer.
    • Changed the CLI app's name from lsreg to swda.
    • Messages in both the CLI and Preference Pane are now a bit more verbose.
    • Under the hood, folded most of the app's feedback to the user into a single displayAlert() function.
  • Fixed

    • Updated the Swift Package Manager manifest to version 5.
    • Updated the SynchronizedArray code and corrected the attribution; Before, I had inadvertently credited an unrelated project with the same name.
    • Various small optimizations, fixes and text corrections.

[1.1.3] - 2018-11-15

  • Fixed

    • Bug causing crash on related to force-unwrapping bundleIdentifier.

[1.1.2] - 2018-10-07

  • Changed

    • Migrated to Swift 4.2
    • Force Static linking of standard library, which should fix issues running on Mojave.

[1.1.1] - 2018-04-15

  • Changed

    • Small changes for Swift 4.1.

[1.1.0] - 2017-09-27

  • Changed

    • Migrated code to Swift 4.
  • Fixed

    • Fixed an unwrapped Optional when changing associations in the "Applications" tab.
    • Fixed CLI tool.
    • Some other cleanups.

[1.0.0] - 2017-05-01

  • Added

    • Initial release!
  • Changed

  • Fixed


Stars: 1188
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Version 2.0.1
3 years ago
  • Fixed

    • CLI: Crash when displaying the results for setHandler with shortcuts such as internet, browser, email, etc.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics