I'm developing application for macOS which require screen recording. Each time when I will recompile code, I have to manually add exception for this application in Security & Privacy (Screen Recording tab). Is there a way, to allow it only once?
I was trying to acces it using this code:
if( !CGPreflightScreenCaptureAccess())
{
print("not granted!")
let result = CGRequestScreenCaptureAccess()
if(result == true)
{
print("Screen recording granted, thank you.")
}
else
{
print("Not granted! Bye-bye...")
exit(1)
}
}
but CGRequestScreenCaptureAccess does not wait for approval.
I was also trying to poll current status by calling CGPreflightScreenCaptureAccess in a loop, but it always returned false, even after manual approval.
When I run this application from terminal (which have pernament access to screen), everything is working fine. But this way, I cannot debug anything.
Each time when I will recompile code, I have to manually add exception for this application in Security & Privacy (Screen Recording tab).
TCC uses an app’s code signature to confirm that version N+1 of your app is the ‘same code’ as version N. Problems like this are usually caused by your app not having a stable signing identity — either it’s not signed or its ad hoc signed (Signed to Run Locally in Xcode parlance). Once your app has a stable signing identity, TCC should remember it from build to build.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"