Help needed with MacOS: UioHookResult.ErrorAxApiDisabled
First of all, thank you for all your work here! I could create some hotkeys in a MAUI app for Windows in a couple of minutes without any problem. But I'm having issues with Mac Catalyst. I keep receiving the ErrorAxApiDisabled exception and I already gave permissions. Am I missing something? The code is being executed in the main thread.
I have MacOs Sonoma 14.4.
Hi! Thanks for posting this issue! This is definitely weird, the app shouldn't ask for permissions again. Could you please share a minimal reproducible example so that I can poke it around on my machine?
Maybe - and this is a long shot - you should also enable accessibility permissions for VS Code? Since this application is a child process of VS Code, it may help, but I'm not sure since I don't really know how macOS manages these permissions. Might as well try it out though.
Also, you shouldn't run the global hook on the main thread in MAUI apps since the main thread should be used as the UI thread. You should instead call RunAsync and ignore the result - it will then run on a separate thread.
Also, it would be nice if you shared the debug logs of libuiohook. You can find more info in the docs.
Had same problem. Seems to be running when not attaching the debugger (Using Rider as IDE). Thanks for the heads up on not running on the UI thread. This was also my initial thought, but thought I not to question it.
Playing off of your idea of adding the IDE, I am wondering if it is the debugger that actually needs the accessibility access in order to be able to run while debugging.
Thanks @PayProff-Don, that's an interesting thought I haven't considered earlier. I'll check it out when I have some time (I'm not sure when that will actually be, sorry).
@TolikPylypchuk Hello! The same issue. Works on Release build, fail on Debug. Does any chance there is some progress? Or maybe any workaround to make it work with debug
Hello, @titan19! No, I didn't have any progress with that, sorry. I still cannot reproduce the issue on my MacBook, everything works just fine for me :/
I've finally had time to tackle this issue again and was able to reproduce it. I believe this is not an issue with SharpHook itself as I was also able to reproduce it when using macOS APIs directly. I've opened an issue about this, and the solution described there worked for me:
In any case, I believe this to be a signing difference: all macOS apps are signed [1], but unless a signing identity has been specified or a provisioning profile is required, the app will be signed with a placeholder signature when building for debug. Using a placeholder signature has an important side effect when it comes to permissions: changing the app in any way (aka rebuilding it) will usually make macOS' permission system consider it a different app, thus existing permissions don't apply.
The fix is to sign using an actual signing identity, this can be done by adding this to your project file (you'll have to use your own value for CodesignKey):
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> <CodesignKey>Apple Development: J. Doe (XYZXYZXYZ)</CodesignKey> <EnableCodeSigning>True</EnableCodeSigning> </PropertyGroup>
And then rebuilding the app shouldn't reset the permissions.
Hopefully, this solution will also work for you, but in any case, I'm going to close this issue as this is not a problem with SharpHook itself.