{"id":9120,"date":"2014-07-11T12:19:29","date_gmt":"2014-07-11T16:19:29","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=9120"},"modified":"2014-07-11T14:26:25","modified_gmt":"2014-07-11T18:26:25","slug":"scripting-from-a-sandbox","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/07\/11\/scripting-from-a-sandbox\/","title":{"rendered":"Scripting From a Sandbox"},"content":{"rendered":"<p><a href=\"http:\/\/www.objc.io\/issue-14\/sandbox-scripting.html\">Craig Hockenberry<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.objc.io\/issue-14\/sandbox-scripting.html\">\n<p>That&rsquo;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.<\/p>\n<p>But sometimes you&rsquo;ll want to help the end user install scripts that you&rsquo;ve written. Chances are, you&rsquo;re a better programmer than your average customer, and you know how to write code that makes your app work better with your customer&rsquo;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&rsquo;s scripts folder?<\/p>\n<p>The solution here is to get permission to write into that folder. In Xcode, you need to update your app&rsquo;s Capabilities to &ldquo;User Selected File to Read\/Write,&rdquo; under App Sandbox &gt; File Access. Again, user intent is the guiding factor here, since you&rsquo;re being given permission to add scripts to the folder.<\/p>\n<\/blockquote>\n<p>This works, technically, but I had thought it was not allowed by the Mac App Store rules, probably <a href=\"https:\/\/developer.apple.com\/appstore\/mac\/resources\/approval\/guidelines.html#functionality\">rule 2.30<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/appstore\/mac\/resources\/approval\/guidelines.html#functionality\"><p>Apps that do not comply with the Mac OS X File System documentation will be rejected<\/p><\/blockquote>\n<p>This is the same reason that applications aren&rsquo;t allowed to have a button to install PDF services. Has this changed?<\/p>\n<p>Update (2014-07-11): <a href=\"https:\/\/twitter.com\/chockenberry\/status\/487662559336484864\">Craig Hockenberry<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/chockenberry\/status\/487662559336484864\"><p>xScope 4 does it. The User Scripts folder is documented as a place where this stuff MUST go.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Craig Hockenberry: That&rsquo;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&rsquo;ll want to help the end user install scripts that you&rsquo;ve written. Chances are, you&rsquo;re a better programmer than your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[159,30,39,71,53],"class_list":["post-9120","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-applescript","tag-mac","tag-macappstore","tag-programming","tag-sandboxing"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=9120"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9120\/revisions"}],"predecessor-version":[{"id":9124,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9120\/revisions\/9124"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=9120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=9120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=9120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}