Cannot Launch Containing App from Today Widget on Catalina

126 Views Asked by At

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/Notification app. Otherwise the main app and wiidget work as expected.

The problem looks a lot like this one.

Any suggestions are appreciated.

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.

0

There are 0 best solutions below