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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.