{"id":36518,"date":"2022-07-14T15:30:13","date_gmt":"2022-07-14T19:30:13","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=36518"},"modified":"2022-07-14T15:30:13","modified_gmt":"2022-07-14T19:30:13","slug":"inject-hot-reloading-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/07\/14\/inject-hot-reloading-in-swift\/","title":{"rendered":"Inject: Hot Reloading in Swift"},"content":{"rendered":"<p><a href=\"https:\/\/www.merowing.info\/hot-reloading-in-swift\/\">Krzysztof Zab&#x142;ocki<\/a> (<a href=\"https:\/\/twitter.com\/merowing_\/status\/1510899797946994688\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/www.merowing.info\/hot-reloading-in-swift\/\">\n<p>If you only used Apple platforms, you can be surprised to learn how many platforms have embraced hot-reloading decades ago. Whether you write Node or any other JS framework, there is a setup for you to use hot-reloading. <code>Go<\/code> also offers hot-reloading (This blog leverages that feature).<\/p>\n<p>[&#8230;]<\/p>\n<p>Eight years have passed since Swift Playgrounds are still here, and they got better, but are they reliable? [&#8230;] In my experience: not really.<\/p>\n<p>[&#8230;]<\/p>\n<p>Similar story [with SwiftUI Previews], it&rsquo;s great when it works, but it works unreliably in bigger projects and tends to break more times than they work.<\/p>\n<p>[&#8230;]<\/p>\n<p>I recognized that <a href=\"https:\/\/github.com\/krzysztofzablocki\/Playgrounds\">Playgrounds<\/a> approach might have been too heavy-handed, so today, I&rsquo;m open-sourcing. A very focused micro-library called <a href=\"https:\/\/github.com\/krzysztofzablocki\/Inject\">Inject<\/a> that, when paired with <a href=\"https:\/\/github.com\/johnno1962\/InjectionIII\">InjectionForXcode<\/a>, will make your Apple development much more efficient and enjoyable!<\/p>\n<p>[&#8230;]<\/p>\n<p>Hosts leverage auto-closure, so each time you inject code, we create a new instance of your type with the same arguments as initially, allowing you to iterate on any code, memory layout, and everything else. The only thing that you can&rsquo;t change is your initializer API.<\/p>\n<\/blockquote>\n\n<p>See also: his previous project <a href=\"https:\/\/github.com\/krzysztofzablocki\/Traits\">Traits<\/a>.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2014\/10\/23\/playgrounds-for-objective-c\/\">Playgrounds for Objective-C<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Krzysztof Zab&#x142;ocki (tweet): If you only used Apple platforms, you can be surprised to learn how many platforms have embraced hot-reloading decades ago. Whether you write Node or any other JS framework, there is a setup for you to use hot-reloading. Go also offers hot-reloading (This blog leverages that feature). [&#8230;] Eight years have passed [&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":"2022-07-14T19:30:15Z","apple_news_api_id":"58870ebe-743c-40dc-8e14-d8c6fdf27995","apple_news_api_modified_at":"2022-07-14T19:30:16Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AWIcOvnQ8QNyOFNjG_fJ5lQ","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":[75,31,2078,30,2077,74,71,2080,901,1812,226],"class_list":["post-36518","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-developertool","tag-ios","tag-ios-15","tag-mac","tag-macos-12","tag-opensource","tag-programming","tag-swift-playgrounds","tag-swift-programming-language","tag-swiftui","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36518","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=36518"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36518\/revisions"}],"predecessor-version":[{"id":36519,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36518\/revisions\/36519"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=36518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=36518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=36518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}