TOpenDialog/NSOpenPanel not working in a sandboxed Delphi app
Asked Answered
E

1

7

There seems to be a problem with the TOpenDialog in a Firemonkey application, which is sandboxed for the Mac Appstore. I use XE3, but it is also present in XE2. I actually found a QC report here, but it is still unresolved:

http://qc.embarcadero.com/wc/qcmain.aspx?d=105344

Has anyone had the same problem, or any ideas how to work around it?

It is very easy to check. Just put a TOpenDialog on a form and call the Execute method. Sign and sandbox the application according to the Embarcadero instructions:

http://docwiki.embarcadero.com/RADStudio/en/Mac_OS_X_Application_Development

When Execute is called there is a delay, the app freezes for a moment, but nothing is shown. There are no exceptions or error messages. If the app is not sandboxed the dialog works properly.

This code also does not work, so the problem is probably somewhere in the TNSOpenPanel, which is called by the TOpenDialog, but unfortunately I could not find it.

var
  LOpenDir: NSOpenPanel;
begin
  LOpenDir := TNSOpenPanel.Wrap(TNSOpenPanel.OCClass.openPanel);
  LOpenDir.runModal;
  LOpenDir.release;

I read in the Apple docs that with Sandbox the NSOpenPanel is derived from different classes, compared to the one without a sandbox. I guess this is the cause of the problem.

Any ideas would be greatly appreciated. We can't really publish an app that has to work with files without Open/Save dialogs :)

Btw, I tried several combinations of the Entitlements in Project Options, but they had no effect.

Embarkment answered 25/11, 2012 at 14:23 Comment(2)
I got the same issue, any workarounds? Thanks.Tony
I haven't found a workaround so far unfortunately. The only positive thing is that the problem appears on OSX 10.7, but not on 10.8. So far the only solution in my app is to disable the 'Browse' functionality when ran on 10.7 and use only the drag-drop options.Embarkment
H
0

When an application is in sandbox, NSOpenPanel/NSSavePanel should be managed by a transparent module called Powerbox. The normal panels of AppKit framework has no effect. But to enable Powerbox for access to filesystem, the entitlements list should include

com.apple.security.files.user-selected.read-write YES

configuration.

Hyperesthesia answered 25/11, 2012 at 16:59 Comment(5)
Yup, I already tried adding this to the entitlements, but it does not change the behavior. Is there anything specific that I should to call the OpenPanel with the Powerbox module? I think not, but still...Embarkment
Hello Georgiev, I will try and write here the answer as soon as I find a workaround.Hyperesthesia
Hello, I am trying to regenerate your error, however I couldnt manage to codesign the application. I got the error: object file format unrecognized, invalid, or unsuitable. Have you ever faced this situation and how could you codesign your app?Hyperesthesia
Hello, thanks for trying to help. I did not have problems with the codesigning and didn't receive any errors there. Just followed the automated signing steps here: docwiki.embarcadero.com/RADStudio/XE3/en/… Created the "Mac App Certificate" and "Mac Installer Certificate" from Apple, installed them on my Mac, set the names in the Provisioning and that was pretty much it. I'll see if I can get that error if I play with the settings.Embarkment
Ok, My Mac is Mountain Lion, maybe the error is about that. I will try to fix it.Hyperesthesia

© 2022 - 2024 — McMap. All rights reserved.