{"id":41736,"date":"2024-01-10T15:38:08","date_gmt":"2024-01-10T20:38:08","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=41736"},"modified":"2024-10-09T15:39:38","modified_gmt":"2024-10-09T19:39:38","slug":"mac-app-sandboxing-interferes-with-drag-drop","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2024\/01\/10\/mac-app-sandboxing-interferes-with-drag-drop\/","title":{"rendered":"Mac App Sandboxing Interferes With Drag &#038; Drop"},"content":{"rendered":"<p><a href=\"https:\/\/wadetregaskis.com\/mac-app-sandboxing-interferes-with-drag-drop\/\">Wade Tregaskis<\/a>:<\/p>\n<blockquote cite=\"https:\/\/wadetregaskis.com\/mac-app-sandboxing-interferes-with-drag-drop\/\">\n<p>Merely inspecting the UTIs in the pasteboard is fine &#x2013; that doesn&rsquo;t interfere with anything.  So if all you care about is if <em>any<\/em> kind of file (or folder) is being dragged, you&rsquo;re set.  But if you want to only react to <em>some<\/em> types of files or folders, you need to know more.<\/p>\n<p>If you ask for the URL &#x2013; even without actually <em>using<\/em> it &#x2013; you trigger some behind the scenes activity involving app sandboxing.  This prevents the file being made accessible to your app if &amp; when it actually is dropped into your app.<\/p>\n<p><em>When things are working correctly<\/em>, when a file is dragged and dropped onto a receptive view in your app a link to that file is created inside your own app&rsquo;s container.  It&rsquo;s that <em>link<\/em> that you actually have access to &#x2013; the original file cannot be accessed directly.  That link seems to persist for a while &#x2013; perhaps until your app is quit &#x2013; so once you have it you&rsquo;re set.<\/p>\n<p>I don&rsquo;t know why merely peeking at the file path (URL) prevents this link being created, but it does.<\/p>\n<\/blockquote>\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/08\/26\/sandboxing-a-command-line-tool-with-paths-as-arguments\/\">Sandboxing a Command Line Tool With Paths As Arguments<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/10\/24\/modern-appkit-file-permissions\/\">Modern AppKit File Permissions<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/02\/05\/sandbox-limitation-on-number-of-files-that-can-be-opened\/\">Sandbox Limitation on Number of Files That Can Be Opened<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2015\/07\/17\/security-scoped-bookmarks-and-webarchive-files\/\">Security-Scoped Bookmarks and .webarchive Files<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Wade Tregaskis: Merely inspecting the UTIs in the pasteboard is fine &#x2013; that doesn&rsquo;t interfere with anything. So if all you care about is if any kind of file (or folder) is being dragged, you&rsquo;re set. But if you want to only react to some types of files or folders, you need to know more. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2024-01-10T20:38:11Z","apple_news_api_id":"b7f5cb4f-d403-492b-83a9-9ba5ab4250f6","apple_news_api_modified_at":"2024-01-10T20:38:11Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/At_XLT9QDSSuDqZulq0JQ9g","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":[131,30,2385,1670,71,53,2669],"class_list":["post-41736","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-mac","tag-macos-14-sonoma","tag-pasteboard","tag-programming","tag-sandboxing","tag-security-scoped-bookmarks"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/41736","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=41736"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/41736\/revisions"}],"predecessor-version":[{"id":41737,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/41736\/revisions\/41737"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=41736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=41736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=41736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}