Issues using File::currentApplicationFile with unsigned macOS applications

If my macOS app is flagged as being from an ‘unidentified developer’ (which will be the case if I share my unsigned app with someone online), I’ve noticed that File::currentApplicationFile (and File::currentExecutableFile) will return a file location different from what I would expect - the actually file location returned is in the “/private/var/folders/” directory. I’m assuming this is a macOS security behaviour.

However I have found that if I use File::currentApplicationFile to set the initialFileOrDirectory of a FileChooser object, then the OS file browser window does display the directory I would expect. But so far this is the only case I’ve found where File::currentApplicationFile does what I would expect.

Is this something that can be rectified in the JUCE library code? Or is this a security behaviour of macOS that can’t be changed?

I’m running JUCE 6.0.8, Xcode 12.4, macOS SDK 11.2, macOS 10.15.7.