In attempting to create a Launch Helper as per the Apple docs (and tutorial-ized), I seem to be hitting a hiccup caused by porting the Objective-C code into Swift... who's compiler couldn't be any more redundant in this case.
import ServiceManagement
let launchDaemon: CFStringRef = "com.example.ApplicationLauncher"
if SMLoginItemSetEnabled(launchDaemon, true) // Error appears here
{
// ...
}
The error seems to consistently be:
Type 'Boolean' does not conform to protocol 'BooleanType'
I have tried casting to Bool
in a number of locations, in case I'm simply dealing with a redundant, archaic primitive (either brought in by Obj-C or Core Foundation), to no avail.
Just in case, I have tried casting the response:
SMLoginItemSetEnabled(launchDaemon, true) as Bool
which yields the error:
'Boolean' is not convertible to 'Bool'
...seriously?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…