Friday, July 11, 2014

Scripting From a Sandbox

Craig Hockenberry:

That’s a great solution for scripts written by a user. The user can then open that folder using a control in your app and edit scripts in any way seen fit.

But sometimes you’ll want to help the end user install scripts that you’ve written. Chances are, you’re a better programmer than your average customer, and you know how to write code that makes your app work better with your customer’s other apps. The natural place to put your own scripts is in the application bundle, but how do you get scripts into the user’s scripts folder?

The solution here is to get permission to write into that folder. In Xcode, you need to update your app’s Capabilities to “User Selected File to Read/Write,” under App Sandbox > File Access. Again, user intent is the guiding factor here, since you’re being given permission to add scripts to the folder.

This works, technically, but I had thought it was not allowed by the Mac App Store rules, probably rule 2.30:

Apps that do not comply with the Mac OS X File System documentation will be rejected

This is the same reason that applications aren’t allowed to have a button to install PDF services. Has this changed?

Update (2014-07-11): Craig Hockenberry:

xScope 4 does it. The User Scripts folder is documented as a place where this stuff MUST go.

Comments RSS · Twitter

Leave a Comment