How to call SMLoginItemSetEnabled in Mac Catalyst project ?
Our application needs to run automatically at Macos system login. We developed the MacOS app using Mac Catalyst. Normally, MAC projects do this by calling SMLoginItemSetEnabled, but SMLoginItemSetEnabled cannot be called in the MAC Catalyst project.
In the <ServiceManagement/ServiceManagement.h> are defined as follows:
#if !TARGET_OS_IPHONE #include <Security/Authorization.h> #include <ServiceManagement/SMLoginItem.h> #else // !TARGET_OS_IPHONE
The macro “TARGET_OS_IPHONE” is 1 in Mac Catalyst project.
Does anyone know how to resove this problem? Thank you!
You are correct that SMLoginItemSetEnabled
is not supported under Mac Catalyst. This is less than ideal and I encourage you to file a bug requesting that it be made available.
Please post your bug number, just for the record.
As to workarounds, from a packaging perspective Mac Catalyst apps are Mac apps, so you can package a Serivce Management login item in your app just like you would with any other Mac app. The only sticking point here is calling SMLoginItemSetEnabled
itself.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"