I have a suite of tests for a macOS target that perform various file access operations (opening files to read/write contents, copying/moving/deleting files, iterating directories, etc.). Any operation that touches the Desktop, Documents or Downloads folder results in a one time ~15 second hang. This only happens once. No matter what order tests are run in, or what filesystem operation happens first, only the first such operation hangs like this, then the rest run nearly instantaneously.
This only happens on a macOS target. If I run the same tests in an iOS target, and perform the same file operations on the same files through the iOS simulator, this freeze doesn't happen. And it only happens in the three folders protected by Transparency, Consent and Control (Desktop, Downloads and Documents).
I first noticed this on C++ filesystem access operations (defined in std::filesystem), but I tested and confirmed it happens through Cocoa APIs too (like [NSData dataWithContentsOfFile]
.
I'm not sure why it would hang rather than just prompt for access (which I have a vague memory of it doing the first time I ran the test suite) or simply fail. But does anyone know of any settings that can be added to, say, Security & Privacy that will stop the hang from occurring? Without it the tests would run in probably a 100th of a second, so 15 seconds is a massive slowdown.