If I create an App without sandbox it can be debugged perfectly. If I go and “Sandbox” it all the directories are at their place, but the app is called xyz.debug - nothing works any more.
There seems to be no way to distinguish (programmatically), even not
Using a constant for "Sandbox"ing
Using a PRAGMA (?) #IF …
Using a Script …
So how please is it possible to debug a sandboxed app professionally? I mean it is clear, you can write a logfile and debug the compiled app with your console and keyboard. Did I miss anything? Checked the docs - but nothing in there.
Do I have to send a kind of “request” then? Who is doing this already and who can help?
I can debug Sandboxed apps on my side… but not sure how yours may work or “the kind of things the app tries to do”, and if some of that kind of things may collide with the Sandboxing itself or the enabled Entitlements set under Build Settings > macOS > Sign > Sandboxing > Edit
It would be helpful to know more about the possible issues your app may fall into when it is sandboxed… or if you can reproduce the same kind of problem with any other project (although minimal) so we can digg more into the potential issue.
OK, true, may be I have to be more precise. Here are my ideas about debugging and sandboxing:
Debugging:
The paths for SpecialFolder.ApplicationData use different paths for debugging and running. This becomes problematic if you want to work with files which you copy there. And yes, you could make a script for that (as I do) but: You do not have a variable for “Sandboxed” to check in your IF statement.
Sandboxing:
I want to use different code inside the builds of my app for sandboxed and non-sandboxed. Conditional #IF does not work for the same reason: There is no variable, pragma or other way to find out?
Sure you can debug - but anything outside differs massively. Thanks for taking care again, Xavier!
Paths, I can understand.
Different code? Not really testing your app.
If you expect to find a file in applicationSupport or Documents, the ACTUAL folder you get from those specialfolder methods will be different locations on your computer.
You cannot drop a file manually and then run your app afterwards.
Your app - sandboxed or not - should check the existence of a file, and create it if it is missing at startup.
If you start with a sandboxed app, do not expect non-sandboxed apps to be able to find ‘your’ files
Your app may need the networking entitlement so the app can connect to the IDE. But I’ve been debugging in sandbox for close to 10 years. It works fine.
Yes, true. Anyhow: In my case I have the same app as a “sandboxed” version and as not sandboxed. So the code differs in many places. Any flag to check this would be helpful for me.
Files: The app contains all files inside its own resources folder. If running, this is in the Apps directory inside the container. The App copies its files to the applicationSupport. This does not work in debugging mode. Or did I miss anything (as so often …)?
Also true. I know. BUT: the path is either APPNAME or APPNAME.debug. What makes it rather difficult for me, because the above mentioned copy process from the resources does not work any more. I get this here: „phaenohelp“ konnte nicht kopiert werden, da du nicht über die erforderlichen Zugriffsrechte für „PhaenoMind LITE.debug“ verfügst. - translated: my files could not be copied, even if it is it’s “own” directory?
May be I have to get the files from the compiled debug version of the app - but I don’t know where that is. Thanks for discussing this with me
Yes, this helps a bit, thanks Tim. Have a kind of this already included.
I would like to exclude some code from the sandboxed version and vice versa from the non sandboxed version. And I would like to have that in the same project …
That sounds like the problem. If you are assembling a path based on the app name, then you are doing it incorrectly.
Recent XOJO versions expose SpecialFolder.Resources
So if you want to copy things from your app’s resources folder to ApplicationData, you use
Var destFile As FolderItem = SpecialFolder.ApplicationData.Child("myapp").child("thefile.dat")
Var srcFile As FolderItem = SpecialFolder.Resources.Child("thefile.dat")
srcFile.CopyTo(destFile)
This works for debug and release.
In terms of sandbox/non sandbox, the destination is a different place.
If you were to examine the path to it at debug time, you might find it contains a complex path, like this sort of thing (this one was for an ios app, but you get the idea)
That was the case. Works now like a charm. Thanks a lot, Jeff you are the best.
Now I am insecure about marking this as the solution - because it is half of it. The source flag thing is still another issue. Or do you have a solution for this also?
I use this in my code.. it may work for you.
I dont deliberately sandbox because I don’t want to use the app store, but MacOS can impose something very like sandboxing if an app isnt installed properly.
if left( app.executableFile.nativePath, 9 ) = "/private/" then
//has been translocated/sandboxed
Heads up, this doesn’t work for Sandboxed only Translocated. I tested this before posting the code I did, and is why I chose SpecialFolder.ApplicationData.Contains("/Library/Containers") for Sandbox checking.