Can UserNotifications be used in a command line program?

I have a cli program which does a thing for a while, and I'd like it to post a notification on the screen when it's done. Note that because it's a standalone program, not an app, it doesn't have a bundle, per se.

I tried to use UserNotifications, but I get an immediate error with the line

 let center = UNUserNotificationCenter.current()

With the error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleProxyForCurrentProcess is nil: mainBundle.bundleURL

My entire program to produce this bug:

import Foundation
import UserNotifications

let center = UNUserNotificationCenter.current()

print("Hello, World!")

You may have better luck using CFUserNotificationDisplayNotice, an older and lower-level notification API.

Can UserNotifications be used in a command line program?
 
 
Q