Friday, June 29, 2012

Livecode: Copy File with Mac Sandbox & Mobile


If you find out RevCopyFile does not work. There an really simple fix, and one that used in mobile with iOS and Android with Livecode that can be used to fix this fast.

It super super simple. Use URL and binfile. like such

put URL ("binfile:" & tPath2File) into URL ("binfile:" & tPath2CopyLoc)

The Variables

tPath2File is the var that holds the path to the location of the file to copy.

tPath2CopyLoc is the var that holds the path to the location to copy the file to.

It works and does not require the use of anything like applescript, VB script or shell. Also it supported with iOS, Android, Sandbox Mac Apps, and all the Livecode supported platforms.

Monday, June 4, 2012

Livecode Mac Sandboxing

Here an overview for Livecode built apps enabling Sandboxing for the Mac apps store. I includes an video walk over on you tube for testing your Livecode built app against the sandbox security.

Some item you will need to get this to work with Livecode
• Livecode Version 5.5 or later (This version includes Power Box Dialogs for file and folder access, when  sandbox entitlements are chosen for such, previous version will crash and not work)
• An Mac Paid Development Account from Apple ($99 US)
• An Mac CPU running 10.7 or later (suggest having the most latest public release of OSX as newer entitlements are added pre release that make more things work.)
• Download and add your Mac App Store certificates to your machine for Code signing
• An sandbox entitlement file (This can be created in Xcode, and Text editor or using an 3rd party tool such as RB Package Maker Studio)

You can code sign by the command line or use an 3rd party tool (I using  RB Package Maker Studio as it make it more simple and catches problems before hand. RB Package Maker Studio is said to be for Real basic but works with an Mac app, including apps made with Livecode, Mac Ruby, Unity 3D and Other development tools. )

There two current gothias with Livecode built apps :

1. All Livecode built apps for Mac return an Print Violation , even if your app does not print. Fix this by enabling the Print Entitlement "com.apple.security.print"

2 Power Box Dialogs do not work correctly with the "as sheet" syntax. Current Fix do not sheet file and folder dialogs. (The video will show what happens if you do.)


--

To access your own apps sandbox containers use the specialFolderPath() Livecode Syntax.

Such as:

specialFolderPath("Home")
returns:
/Users/username/Library/Containers/com.yourbundlename.yourappname/Data
specialFolderPath("Documents")

returns:
/Users/username/Library/Containers/com.yourbundlename.yourappname/Data/Documents

specialFolderPath("Temporary")
returns:
/Users/username/Library/Containers/com.yourbundlename.yourappname/Data/Library/Caches/TemporaryItems

Go ahead and try it for your self. Also Not everything works, any app the access an older system dialog will fail, such as answer record. There is some thing like this that need an bug report issued for an future fix. However most items work with sandbox enabled.

Also beware that some shell function and command line tools will not work, while most do. Items like screencapture will not because it an global system level item, and is not seen as secure. The best way to determine if your apps will work is to enable sandboxing and test for violations. It maybe you just need to recode some areas or recode the whole project. Also some apps may work 100% out of the box with no code changes.

Have fun, and remember follow the guidelines apple has published on the subject. This just confirms that Yes Livecode built apps do work with Sandboxing.

Edit: The best 3rd party tool I use now is App Wrapper (link). It works awesome with Xojo and good with Livecode. So it now the best all around solution (I suggest using the the full non mini version, as it supports way more stuff, and is worth the money. Also its developer is very helpful.)