It is build as a single un-bundled binary, and installed away from regular user access at /Library/MyCompany/executables/
When I try to init a reference to UNUserNotificationCenter:
Code Block UNUserNotificationCenter *unc = [UNUserNotificationCenter currentNotificationCenter];
I immediately have an exception, like thus:
Code Block 2021-05-02 19:57:39.297823+0300 agent[12504:225879] *** Assertion failure in +[UNUserNotificationCenter currentNotificationCenter], /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/UserNotifications/UserNotifications-281.6/UNUserNotificationCenter.m:44 2021-05-02 19:57:39.299464+0300 agent[12504:225879] [General] An uncaught exception was raised 2021-05-02 19:57:39.299518+0300 agent[12504:225879] [General] bundleProxyForCurrentProcess is nil: mainBundle.bundleURL file:///Users/mshneor/Library/Developer/Xcode/DerivedData/agent-dgvdlbtivmsjdgdkhhjwaxgrkyht/Build/Products/Debug/
Obviously the problem is bundleProxyForCurrentProcess is nil: mainBundle.bundleURL
Now... I could try to bundle my agent somehow, but that's a bit awkward, and I don't know how - it's not an App, and It's not a part of any App, and I don't know about a special "Code Bundle" type (like plugins etc.) that fits a LaunchAgent. Moreover - it will never be "launched" by it's info.plist in the bundle - only via the .plist in /Library/LaunchAgents by launchd.
So... is it possible to work around this? Could I somehow tell my Agent's process "Here is our main-bundle" at runtime, and provide a special bundle the agent is not embedded in?
what does UNUserNotificationCenter need from main bundle? maybe I can supply this programmatically in advance?
Any hint will be greatly appreciated.