{"id":31535,"date":"2021-02-04T21:28:24","date_gmt":"2021-02-05T02:28:24","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=31535"},"modified":"2021-02-08T14:51:59","modified_gmt":"2021-02-08T19:51:59","slug":"deleting-deriveddata-the-right-way","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/02\/04\/deleting-deriveddata-the-right-way\/","title":{"rendered":"Deleting DerivedData the Right Way"},"content":{"rendered":"<p><a href=\"https:\/\/lapcatsoftware.com\/articles\/DerivedData.html\">Jeff Johnson<\/a>:<\/p>\n<blockquote cite=\"https:\/\/lapcatsoftware.com\/articles\/DerivedData.html\">\n<p>Finder is good about automatically unregistering apps with Launch Services when you put them in the trash and empty it (but not before emptying the trash). However, the <code>rm<\/code> command-line tool bypasses the trash, and thus also bypasses Launch Services. This means that any registered apps in the removed folder remain in the Launch Services database, effectively forever<\/p>\n<p>[&#8230;]<\/p>\n<p>I know that a lot of developers like to use a command-line tool to delete DerivedData. So the question is, how do you do this the right way? The answer is, of course, to do it like Finder! You can use AppleScript to control Finder, and you can call AppleScript from Terminal with the <code>osascript<\/code> command-line tool.<\/p>\n<\/blockquote>\n\n<p>Presumably, <code><a href=\"https:\/\/developer.apple.com\/documentation\/appkit\/nsworkspace\/1530465-recycleurls\">-[NSWorkspace recycleURLs:completionHandler:]<\/a><\/code> can also be used to do this programmatically.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/11\/26\/slow-xcode-11-objective-c-builds\/\">Slow Xcode 11 Objective-C Builds<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/03\/29\/reclaiming-disk-space-from-xcode\/\">Reclaiming Disk Space From Xcode<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2015\/05\/29\/the-unofficial-guide-to-xcconfig-files\/\">The Unofficial Guide to xcconfig Files<\/a><\/li>\n<\/ul>\n\n<p id=\"deleting-deriveddata-the-right-way-update-2021-02-08\">Update (2021-02-08): <a href=\"https:\/\/twitter.com\/tempelorg\/status\/1354743424839274498\">Thomas Tempelmann<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/tempelorg\/status\/1354743424839274498\">\n<p><code>NSWorkspace<\/code> <code>recycleURLs<\/code> creates a unique thread for each file to be deleted pre-10.15. And if you delete &gt; 8200 items at once, you get a crash in 10.12 and 10.13 due to thread exhaustion.<\/p>\n<\/blockquote>\n\n<p>But I think that only refers to top-level items passed as parameters, so it should be fine for this purpose.<\/p>\n\n<p>Ali Rantakari&rsquo;s <a href=\"https:\/\/github.com\/ali-rantakari\/trash\">trash<\/a> is a command-line tool that uses Apple events to tell Finder to move a file to the trash.<\/p>","protected":false},"excerpt":{"rendered":"<p>Jeff Johnson: Finder is good about automatically unregistering apps with Launch Services when you put them in the trash and empty it (but not before emptying the trash). However, the rm command-line tool bypasses the trash, and thus also bypasses Launch Services. This means that any registered apps in the removed folder remain in the [&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":"2021-02-05T02:28:27Z","apple_news_api_id":"907b4ae2-ecad-4015-ab25-09ef85cd463d","apple_news_api_modified_at":"2021-02-08T19:52:02Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAQ==","apple_news_api_share_url":"https:\/\/apple.news\/AkHtK4uytQBWrJQnvhc1GPQ","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":[438,30,1891,71,226],"class_list":["post-31535","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-launchservices","tag-mac","tag-macos-11-0","tag-programming","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31535","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=31535"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31535\/revisions"}],"predecessor-version":[{"id":31585,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31535\/revisions\/31585"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=31535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=31535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=31535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}