I'm trying to write an OSX app (not iOS) that prevents the system from going to sleep when certain things are happening. To do so, I'm trying to access the pwr_mgt
submodule of IOKit from a MacOS app using Swift.
In XCode, I've indicated that I want to use the IOKit framework, and in code, I'm have declared import IOKit
. Although IOKit's classes/methods import fine (I can see them with auto-complete when I type IO*Whatever), the ones relating to power management don't show up.
I've tried to instead import IOKit.pwr_mgt
, but the compiler complains that the submodule can't be found.
<unknown>:0: error: missing required module 'pwr_mgt'
From other documentation for how to do this with Objective-c, the classes that I need to access (amongst others) are:
IOPMAssertionCreateWithName
IOPMAssertionID
IOPMAssertionRelease
CFStringRef
CFSTR
I'm not sure if there is a solution to this problem in older Xcode betas, but on Beta 7 (and I imagine in Xcode 6.1 too)
import IOKit.pwr_mgt
works fine in newer betas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With