alionthego
alionthego

Reputation: 9773

How can I access IOPSCopyPowerSourcesInfo from the IOKit framework in my SwiftUI iOS internal app

I have an internally distributed iOS app that needs to provide user with detailed battery info beyond battery level and state. It seems the only way to do this is using the IOKit framework. I have added this framework to my SwiftUI app using the following import in the bridging header:

#import <IOKit/IOKitLib.h>

But when I try to use the IOPSCopyPowerSourcesInfo method it is not found in scope. I have tried to use the following import:

#import <IOKit/ps/IOPowerSources.h>

But I get a file not found error trying to import this library.

I have seen from some past posts that people have been able to access IOPSCopyPowerSources from iOS in the past. Just wondering if there is any other way to go about this. I want to access the device battery health.

Again it's an internally distributed app that will not be going through the AppStore so review rejection is not an issue.

Upvotes: 0

Views: 61

Answers (0)

Related Questions