Sounds simple.
Nothing about this stuff is simple O-:
But only for .fileImporter(…)
. I don't need to do that for
dragged folders or folders opened with NSOpenPanel
.
That’s interesting, and it’s hard to understand without a historical perspective.
Note I’m going to assume terms from On File System Permissions here.
When we first implemented App Sandbox we made the decision to ‘auto start’ the URLs coming in via the standard file panels, drag’n’drop, and so on. So, you don’t have to call {start,Stop}AccessingSecurityScopedResource()
on those. I’m not sure why we did this, but I suspect it was choice to promote source code compatibility. That is, we wanted to make it easier for folks to adopt App Sandbox.
However, that choice has a number of downsides. Most notably, this auto start behaviour effectively leaks sandbox extension. This leads to a long-standing bug in sandboxed apps: If you select thousands of files in the open panel, things fail badly.
It also presents problems for the cross-platform .fileImporter(…)
API. On macOS, should it follow the behaviour of the open panel? Or should it be consistent with the other SwiftUI platforms? Clearly the SwiftUI folks chose the latter, and it’s hard to fault them for that.
On the plus side, this auto start helps with MAC. MAC reuses a bunch of sandbox infrastructure. However, it needs binary compatibility. So, unlike App Sandbox, it can’t require developers to change their code.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"