How to check if a sandboxed app already has the access permission to a URL

I want to check whether a sandboxed application already has access permission to a specific URL.

Based on my investigation, the following FileManager method seems to be able to determine it:

FileManager.default.isReadableFile(atPath: fileURL.path)

However, the method name and description don't explicitly mention this use case, so I'm not confident there aren't any oversights.

Also, since this method takes a String path rather than a URL, I'd like to know if there's a more modern API available.

I want to use this information to decide whether to prompt the user about the Sandbox restriction in my AppKit-based app.

You can use the "isReadable" value from URLResourceValues.

However, it sounds like you're not approaching this from the right direction. You should never need to do this in the first place. Your app shouldn't attempt to read random files. It should only attempt to access files that the user has specifically requested. And even then, you shouldn't check readability. That's not reliable. Instead, just try to do what the user asked and report an error if it fails.

How to check if a sandboxed app already has the access permission to a URL
 
 
Q