Mac sandbox entitlement read/write documents folder for help file

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

benco5000
Posts: 11
Joined: Fri Mar 05, 2010 9:51 pm

Mac sandbox entitlement read/write documents folder for help file

Post by benco5000 » Sat May 02, 2020 2:18 am

I have a pdf help file that is embeded in a global property.

When the user requests the help file, it checks to see if the pdf help file exists and if not, it will create it in the users documents folder. Why am I doing this? Because apparently the browser widget does not traverse hidden folders? So I have to write it out somewhere (unless there is another way?) I'm open to suggestions.

The brower widget works well to scale and scroll the help file prior to sandboxing.
However; if I sandbox the app, the help file no longer displays and the app locks up with the rainbow circle cursor.

Is there is a specific entitlement that would make this work / OR / is there another way to load this file into the browser widget directly from the card?

Thanks,
Ben

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mac sandbox entitlement read/write documents folder for help file

Post by Klaus » Sat May 02, 2020 1:41 pm

Hi Ben,

you should add the PDF to your runtime via the "Copy files" tab in the "Standalone Application Settings" for your stack.
Then you will find it here in your runtime on ANY platform: -> specialfolderpath("resources" & "/your_pdf_here.pdf")

So this should do the trick and no need to copy it to the users document folder:

Code: Select all

...
put specialfolderpath("resources" & "/your_pdf_here.pdf") into tURL
## Important, remove SPACES:
replace SPACE with "%20" in tURL
set the url of widget "your browser here" to tURL
...
Best

Klaus

benco5000
Posts: 11
Joined: Fri Mar 05, 2010 9:51 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by benco5000 » Sat May 02, 2020 11:28 pm

Thank you Klaus for the assistance.
Still not working for me after sandboxing the app for mac app store.
By the way -- I couldn't figure out how to escape the dot [.] so the paths are a little ugly.

I tried this first a while back and tried it again this morning after your suggestion to see if I had missed anything.
Some new knowledge I found from this exercise based on your suggestion was this:

In the messagebox:

Code: Select all

put specialFolderPath("Resources"       & "myHelp\.pdf")           // -- empty
put specialFolderPath("Resources")      & "myHelp\.pdf"            //-- /Users/Ben/Documents/projectDirmyHelp\.pdf
put specialFolderPath("Resources/")     & "myHelp\.pdf"            //-- myHelp[.]pdf
put specialFolderPath("Resources")      & "/myHelp\.pdf"          //-- /Users/Ben/Documents/projectDir/myHelp\.pdf
Standalone Version:
replace SPACE with "%20" in tURL <-- although this shouldn't matter since I typically don't use spaces
answer tURL with "OK"

Code: Select all

put specialFolderPath("Resources"    & "iSavHelp\.pdf") into tURL    // -- empty
put specialFolderPath("Resources")   & "myHelp\.pdf" into tURL       // -- /path/to/myApp/myApp[.]app/Contents/Resources/_MacOSmyHelp\.pdf
put specialFolderPath("Resources/")  & "myHelp\.pdf" into tURL       //-- myHelp\.pdf
put specialFolderPath("Resources")   & "/myHelp\.pdf" into tURL      // -- /path/to/myApp/myApp\.app/Contents/Resources/_MacOS/myHelp\.pdf
The only entry I can seem to make work is the last entry, although one would think the 'myHelp[.]pdf' would work at the root. It did not for me. I even tried placing it all along the path within the app and in most subdirectories to see if it would pick it up anywhere.

The last entry showing the full path will compile and operate PRIOR to sandboxing the app as is required on the mac app store.

However, after entitlements[.]plist with the com\.apple\.security\.app-sandbox setting to true is applied, and when attempting to view the help file it no longer displays. The app then appears to hang (with high cpu utilization I might add) with a spinning colored beach ball. The only way I have found to get out is to abort using the activity monitor. I don't think it's the version of LiveCode since I've tried it on 9\.5\.1 and 9\.6\.0 (dp 2)

For reference -
I'm also using a sqlite database which does not complain about paths. It appears to work just fine even with the sandboxing of the app. I'm creating the sqlite database in the Support folder. I'm able to read/write/install etc... into that folder without issue, but the Browser widget could not see that folder (now I'm assuming) since it's hidden in the Users Library. I tested it on a hidden folder and a regular folder and when a folder is hidden the Browser widget appears to not follow the path even though it exists. I could perhaps be missing a special character to notify the Browser widget that it is following a hidden path.

hmmmm... what to do what to do .....

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mac sandbox entitlement read/write documents folder for help file

Post by Klaus » Sun May 03, 2020 12:41 am

There is really no need to escape anything except the spaces! :-)
LC takes care of that, so just use:

Code: Select all

...
put specialFolderPath("resources") & "/myHelp.pdf" into tURL
...
Note the slash, specialfolderpath codes do not return a trailing slash, so we need to add it.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Mac sandbox entitlement read/write documents folder for help file

Post by FourthWorld » Sun May 03, 2020 12:42 am

Why do you need to escape the dots?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

benco5000
Posts: 11
Joined: Fri Mar 05, 2010 9:51 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by benco5000 » Sun May 03, 2020 1:07 am

For some reason the forum post would not let me post anything with a dot in the text.
It kept saying I’m not allowed to post a url and to remove myPath.
After I changed all those it said for me to remove the 9. etc for the version numbers so I changed those as well.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by bogs » Sun May 03, 2020 11:31 am

FourthWorld wrote:
Sun May 03, 2020 12:42 am
Why do you need to escape the dots?
The boards see anything with a dot in it and no spaces as a url, ie.
this.isn't.a.url ## but gets treated as one...
This doesn't get flagged. ## has a period, but board treats it like a sentence...
benco5000 wrote:
Sun May 03, 2020 1:07 am
For some reason the forum post would not let me post anything with a dot in the text.
When you hit 10 posts, you won't see that kind of error anymore.
Image

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mac sandbox entitlement read/write documents folder for help file

Post by Klaus » Sun May 03, 2020 5:39 pm

bogs wrote:
Sun May 03, 2020 11:31 am
When you hit 10 posts, you won't see that kind of error anymore.
I recently learned from Heather that this magic number is in fact 7 (SEVEN)! :-)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by bogs » Sun May 03, 2020 8:18 pm

Hmm. Well, I remember getting my information from you when we were discussing '10' being a magic number :P
Image

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mac sandbox entitlement read/write documents folder for help file

Post by Klaus » Sun May 03, 2020 9:06 pm

Yep, that was the common thinking at that time, but now we know better! :-)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by bogs » Sun May 03, 2020 9:16 pm

Well heck then, let's ask benco5000 to be our guinea pig and test that out for us, since you and I don't have any way to regress to level 7 again :D

So benco5000, when you get to your 7th post, try to paste in a link :shock:
Image

benco5000
Posts: 11
Joined: Fri Mar 05, 2010 9:51 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by benco5000 » Sun May 03, 2020 10:37 pm

ok so here is post number six
this\.is\.not\.a\.real\.link

error:
You can’t post image, email or url links that are external to this domain. Please remove this\.is\.

tried another post for post seven
error:
You cannot make another post so soon after your last.

What's also a bit funny is that I signed up in this forum ten years ago about the time I purchased one of those lifetime hosting memberships... but of course got busy and am just now able to get back to this.
Now I'm having such a rough time with sandboxed apps due to the security that is now necessary in this world.
Even still I wan't to deliver via the app store b/c it is so much easier to manage.
Now I thought the sqlite portion was working but apparently it is not when sandboxed. So now I'm back to square one for sandboxing.
It appears I'm not the only one to experience this, but I'll keep hammering on it, looking for solutions.

Is there any location? at all (I dont' really care where it is) as long as a sandboxed app can have read from and write to one directory.
Even if I have to pre-call out the exact paths, even that would be ok, but I have not yet been able to find the magic combination.

Ben
Last edited by benco5000 on Sun May 03, 2020 10:52 pm, edited 1 time in total.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by bogs » Sun May 03, 2020 10:46 pm

Well, unfortunately that speed thing never goes away heh.
Image

benco5000
Posts: 11
Joined: Fri Mar 05, 2010 9:51 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by benco5000 » Mon May 04, 2020 3:33 am

here is post number seven
and\.this\.is\.not\.a\.real\.link

will it work?

error:
You can’t post image, email or url links that are external to this domain. Please remove and\.

benco5000
Posts: 11
Joined: Fri Mar 05, 2010 9:51 pm

Re: Mac sandbox entitlement read/write documents folder for help file

Post by benco5000 » Mon May 04, 2020 7:47 am

post number eight

one more time today.....
this.is.not.a.real.link will it submit

yes.... yes it did.... :-)

it's almost 2:00am and I'm shutting down for the night....

Post Reply

Return to “Mac OS”