Gusev Slava
Gusev Slava

Reputation: 2204

Using IOKit in macOS app

I found several topics where arises the same question, but they're pretty old and most of them don't have a definite answer, or the answer is applicable to iOS only. Also some sources say it's prohibited while other disagree.

For example, here or here about iOS.

I'm interested whether IOKit can be used for macOS applications - note! macOS, not iOS - to get only battery information.

If no, I'd like to find out, how apps like Battery Health work.

What are your guesses? Thanks.

Upvotes: 3

Views: 1519

Answers (1)

pmdj
pmdj

Reputation: 23428

The IOKit.framework is a reasonably well documented, public API on macOS. Many apps and most 3rd party device drivers use it. For the Mac App Store, entitlements restrictions apply.

Regarding Mac battery status, you probably want to take a look at the IOPMPowerSource/AppleSmartBattery objects. The output from running the following command on the Terminal should give you an idea of what information is available:

ioreg -w 0 -irc IOPMPowerSource

The AppleSmartBattery source code is available, that's probably your best reference.

Upvotes: 1

Related Questions