4

I am making a project that need access to files, so parts of my hard drive, and the right to record my screen. I am on MacOS 11.6.

Every time I recompile and re-run my app, it asks me again to grant access to those things.

I have tried developer tools in Privacy, but it did nothing.

How do I make MacOS stop asking me to do this ?

2 Answers2

1

You need to code sign the application. You can do this by going to the "Signing and Capabilities" tab in the project settings and checking "Automatically manage signing". You will need to log into your Apple developer account to use as the "Team".

0

I found a workaround, hope it can help anyone who has to face the MacOS sandboxing system:

I was using an executable, but when I switched to an app bundle, it only asked me the first time, and never after recompiling the whole thing.

I think that since app bundles considered as executables even though they're just containers, means that you can change the executable (by recompiling for example), without actually deleting what System Preferences was pointing to.

EDIT:

At some point even that wasn't enough, another (and easier) solution is to use /bin/zsh -c /path/to/executable, since zsh is not recompiled, and trusted by Apple since it's the shell.

  • 1
    That is not the correct answer. Mostly you recompile in debug mode and can not just use a workaround "/bin/zsh -c /path/to/executable" in a debugger such as vscode. There must be some developer solution for permission on recompiled apps. – bedbad Feb 07 '23 at 02:11
  • @iantonuk This will be left mark as the solution as it solves the issue. You're however more than welcome to submit a more "official" solution if you have or encounter one. – Oxymore-coder Mar 15 '23 at 13:03