Sandboxed Apps can not be debugged?

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?

Thanks a lot in the name of all of us.

Ping … ping … ping … no one here who has this problem?

Would be nice to have a kind of

#IF TargetSandboxed

or have a PropertyValue reflecting that? Not too hard to do … Xojo?

Hi @Michael_Dettmer

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

For example, “Sandboxing” the provided Eddies Electronics example project: https://drive.google.com/file/d/1yLYxBhw543AOuRAZuc-2b_ni8nSvkKac/view?usp=sharing

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

1 Like

Maybe this will help.

var bSandboxed as Boolean = SpecialFolder.ApplicationData.NativePath.Contains("/Library/Containers/")
2 Likes

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 …)?

…no,…yeeeeesss…it does…

When you say it doesn’t work, what code exactly fails?

But the folder it goes to is a different one than the one you get when not sandboxed.
A sandboxed app gets its own, private ‘pretend’ folders.

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 :+1:

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 …

Please show your code. We have no idea what you are trying to do and what is failing.

1 Like

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)

/Users/abcde/Library/Developer/Devices/60BC3320-91AA-4CCE-8139-00402AD82591/data/Containers/Data/Application/83E60D00-CC83-4819-A359-BEAEC91

1 Like

YESSSS!

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? :smiling_face_with_sunglasses:

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

OK, here a summary of this thread, not perfect but working for me now:

There is no flag for getting control of the source, but I can use Tim’s suggestion here:

The Sandboxing issue is solved with Jeffs instructions:

Thanks Jeff, Tim - I hope this thread will help others to find their way through the jungle :evergreen_tree: :leafless_tree: :palm_tree: :deciduous_tree: :palm_tree:

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.

2 Likes

Good to know.

Checking the environment variables for APP_SANDBOX_CONTAINER_ID would be a good option too.

2 Likes