Open JamesB7 opened 5 years ago
The problem here is that when using this class from ObjC, you always call +[NSSavePanel savePanel]
/+[NSOpenPanel openPanel]
instead of alloc/init. Calling alloc/init was AFAICT never a supported way to create an open/save panel. The reason this worked prior to Catalina is because, on Mojave and earlier, the open/save panels were hosted in-process (except when sandboxed). If you are running in a sandboxed process, or in any process on Catalina, the open and save panels execute out-of-process for security reasons. The only way to create an out-of-process open/save panel is to use those static methods mentioned above.
To fix this problem, use the static OpenPanel
and SavePanel
properties instead of calling the class’ constructor. (In fact, if you look up the constructor for NSOpenPanel or NSSavePanel in appkit.cs, you will see an AdviceAttribute telling you this.) I could try my hand at preparing a PR that would deprecate those two constructors, if the team agrees (and is willing to provide a bit of help; the xamarin-macios repo and I are not friends). Hope this helps!
@wjk you're right. On 10.15 the panels always behave like they are sandboxed, i.e. its now always out-of-process.
Feel free to PR and come ask on #macios-community (gitter) if you hit any snag :)
NSOpenPanel.OpenPanel also returns null to me. Is there something special I might need to call to give it a value?
Steps to Reproduce
Call the NSOpenPanel or NSSavePanel constructor. This only happens on macOS 10.15.
Expected Behavior
It will create the NSOpenPanel/NSSavePanel object.
Actual Behavior
On macOS 10.15, it will fail with 'init returned null'.
Environment
macOS 10.15 Xamarin.Mac Calling mono from the command line. This also happens in my program which is built into a code-signed .app. It worked perfectly on all earlier versions of macOS.
https://github.com/xamarin/xamarin-macios/issues/6474#issue-463324943
Steps to Reproduce
Call the NSOpenPanel or NSSavePanel constructor. This only happens on macOS 10.15.
Expected Behavior
It will create the NSOpenPanel/NSSavePanel object.
Actual Behavior
On macOS 10.15, it will fail with 'init returned null'.
Environment
macOS 10.15 Xamarin.Mac Calling mono from the command line. This also happens in my program which is built into a code-signed .app. It worked perfectly on all earlier versions of macOS.