macOS Objective-C: How to prompt the user for desktop access?

With the recent macOS security enhancements, users are prompted to allow access when an application tries to access, say, the Desktop for the first time.

Our application, at certain points, enters a fullscreen mode that prevents these popups from being visible as they open "behind" the application.

The initial solution to this was to attempt to write then delete a ".temp.txt" file on the user's Desktop as the app was starting up to trigger the popup to appear.

However, it seems that the write/delete on startup works without issue, but as soon as the app tries to do anything with the Desktop afterward, the popup appears... behind the app.

My guess is that the reason the popup isn't appearing at the start is because the app was the process that created the file, and therefore doesn't need special permission to access it.

So, the question: is there any way to trigger the Desktop permission popup explicitly before the application enters full screen??

For context, we're working on macOS 11.6 in Objective-C, and the initial ".temp.txt" is being written using NSData writeToFile, then NSFileManager removeItemAtPath.

is there any way to trigger the Desktop permission popup explicitly … ?

No, but that would make a fine enhancement request. Make sure to include your use case, because this is one that I’ve not seen before.

Please post your bug number, just for the record.

I suspect that you could work around this by trying to enumerate the contents of the Desktop folder.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

macOS Objective-C: How to prompt the user for desktop access?
 
 
Q