ToothFairy 2.8.5
ToothFairy 2.8.5 is a maintenance update of my Bluetooth menu bar utility. It fixes a bug where sometimes ToothFairy wouldn’t auto-launch at login.
An interesting bug was:
-
ToothFairy uses
SMLoginItemSetEnabled()
, which, instead of launching the app directly, launches a helper app that can launch the main app. Originally, it did this usingNSWorkspace.launchApplication(_:)
, but then Xcode reported this as deprecated, so I updated it to the new API,openApplication(at:configuration:completionHandler:)
. There seemed to be no need to report errors in this case, so I just passednil
for the completion handler. The documentation says that the method “Launches the app at the specified URL and asynchronously reports back on the app’s status.” What I didn’t realize, and seems contrary to the documentation, is that it doesn’t just report the success or failure asynchronously, but it seems to also do the launching asynchronously. Sometimes the API would return, the helper app would quit, and this would derail the launching. The fix is to keep the helper running until the completion handler has been called.