Cannot Launch Containing App from Today Widget on Catalina

macOS Catalina 10.15.2

Xcode 11.3 Swift 5


The following code executed in the Widget always returns 'false' in completion:


extensionContext?.open(myAppUrl, completionHandler: { (success) in
  if (!success) {
  os_log("Failed to open app from Today Extension", log: OSLog.mylogs, type:.error )

  }


The main app that contains the widget extension is in an Applications folder and can be launched by an 'Open URL' from an Automator workflow.

There are no error messages in the system log. The launch attempt fails under the widget simulator and on the live Today app. Otherwise the main app and wiidget work as expected.

The problem looks a lot like this.

Any suggestions are appreciated.

Replies

I got the same results on a Mojave system. On further searching I found this 2014 article. This code works:

let sharedApp = NSWorkspace.shared
  if !(sharedApp.open(myAppUrl)) {
  os_log("Failed to open app from Today Extension", log: OSLog.mylogs, type:.error )
  }

It seems that Apple has never added the code in OSX to support the newest Today Widget Extension doc.