beltex / SMCKit

Apple SMC library & tool
https://beltex.github.io/SMCKit
MIT License
472 stars 55 forks source link

SMCWrite error while setting the fan PRM #44

Open Taktoshi opened 4 years ago

Taktoshi commented 4 years ago

When I tried to write smc to set the fan RPM, it returned like this "smc.swift:callSMC(inputStruct:outputStruct:) - IOReturn = -536870207 - kSMC = 0". I figured out the IOReturn code means kIOReturnNotPrivileged. Does anyone have ideas how to solve this problem?

cbosoft commented 4 years ago

Hi, I'm trying to solve this issue right now too. The program needs root privileges to write to SMC.

I don't know how to elevate a swift cocoa app to admin however. If it was a CLI application you could just run it with sudo.

cbosoft commented 4 years ago

Sorry, I know you've closed this.

I want to add on that root privileges in swift needs a privilege helper (e.g. here) to do certain actions. I think you need a paid-up Apple Developer account to do this, but it may be possible to self-sign? I'm not sure.

There's some info from Apple here on code signing and security.

Taktoshi commented 4 years ago

Thanks for your reply. I had solved this issue by the method exactly you said which is the privileged helper. I had achieved the function on my Mac through an apple developer certify (not paid). But I don't know if I can run this on others ' mac. It's my first time to make a Mac app just for fun.

cbosoft commented 4 years ago

Ah good stuff! Glad you got it working. Could you tell me how to get an Apple Dev cert? Or a link to some resources? I'm mucking about with a mac for the first time, all this security stuff is completely new to me!

Taktoshi commented 4 years ago

Just in Xcode preference, in accounts click plus button to add your Apple ID. I just do that